bus error/segfault from PyArg_ParseTuple in initproc with incorrectarg number

M

Miles Lubin

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.

Thanks in advance,
Miles
 
A

Andrew MacIntyre

Miles said:
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.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top