bus error/segfault from PyArg_ParseTuple in initproc with incorrectarg number

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Miles Lubin

    bus error/segfault from PyArg_ParseTuple in initproc with incorrectarg number

    I am using PyArg_ParseTupl e to parse the arguments (ignoring the keyword
    arguments) to my initproc for a type I define.
    It seems that something goes wrong inside PyArg_ParseTupl e 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_ParseTupl e in a normal method.
    Am I not using PyArg_ParseTupl e correctly?

    Here's the relevant code:
    PyObject *a, *b;
    if (!PyArg_ParseTu ple(args, "OO", &a, &b))
    return -1;

    The segfault occurs on this line, not on any line after.

    Thanks in advance,
    Miles
  • Andrew MacIntyre

    #2
    Re: bus error/segfault from PyArg_ParseTupl e in initproc withincorrect arg number

    Miles Lubin wrote:
    I am using PyArg_ParseTupl e to parse the arguments (ignoring the keyword
    arguments) to my initproc for a type I define.
    It seems that something goes wrong inside PyArg_ParseTupl e 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_ParseTupl e in a normal method.
    Am I not using PyArg_ParseTupl e correctly?
    >
    Here's the relevant code:
    PyObject *a, *b;
    if (!PyArg_ParseTu ple(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@bullsey e.apana.org.au (pref) | Snail: PO Box 370
    andymac@pcug.or g.au (alt) | Belconnen ACT 2616
    Web: http://www.andymac.org/ | Australia

    Comment

    Working...