bus error/segfault from PyArg_ParseTuple in initproc with incorrect arg number
Andrew MacIntyre
andymac at bullseye.apana.org.au
Sat Feb 23 19:45:52 EST 2008
Miles Lubin wrote:
> I am using PyArg_ParseTuple to parse the arguments (ignoring the keyword
> arguments) to my initproc for a type I define.
> It seems that something goes wrong inside PyArg_ParseTuple when it gets
> the wrong number of arguments (my format string is "OO");
> if the function isn't given exactly two arguments, I get a bus error on
> OS X and a segfault on Linux.
> If two arguments are given, the code runs as expected.
> This does not occur when using PyArg_ParseTuple in a normal method.
> Am I not using PyArg_ParseTuple correctly?
>
> Here's the relevant code:
> PyObject *a, *b;
> if (!PyArg_ParseTuple(args, "OO", &a, &b))
> return -1;
>
> The segfault occurs on this line, not on any line after.
I have seen bus errors on FreeBSD when python runs out of stack space.
--
-------------------------------------------------------------------------
Andrew I MacIntyre "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au (pref) | Snail: PO Box 370
andymac at pcug.org.au (alt) | Belconnen ACT 2616
Web: http://www.andymac.org/ | Australia
More information about the Python-list
mailing list