473,586 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

bus error/segfault from PyArg_ParseTupl e 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
Feb 22 '08 #1
1 1841
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: an*****@bullsey e.apana.org.au (pref) | Snail: PO Box 370
an*****@pcug.or g.au (alt) | Belconnen ACT 2616
Web: http://www.andymac.org/ | Australia
Feb 24 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1527
by: Rutger Claes | last post by:
While developing a website, there is always a point at which I get "Connection to localhost is lost". If take a look at my server logs I see something like: child pid 17914 exit signal Segmentation fault (11) Is this a coding error, or is it because I use PHP 5.0.3 and it is still buggy? How do I get more information about these...
12
3146
by: Nathaniel Echols | last post by:
I've written a function in C to perform protein sequence alignment. This works fine in a standalone C program. I've added the necessary packaging to use it in Python; it returns three strings and an integer. However, as soon as the function is complete, I get a segfault and the interpreter dies. If I run Python interactively, just...
8
1791
by: Russell E. Owen | last post by:
I'm writing a C extension for numarray and am puzzled about the idiom for error handling. The documentation seems to say one should always decref an array after calling NA_InputArray, etc., to convert numarray args to C arrays. However, the example and also the numarray code suggests that it's OK to return early via (for example)...
3
3364
by: Travis Berg | last post by:
I'm running into a problem when trying to perform a callback to a Python function from a C extension. Specifically, the callback is being made by a pthread that seems to cause the problem. If I call the callback from the parent process, it works fine. The PyObject is static, and holds the same value in both Parent and thread, so I'm at a...
4
5134
by: sjh | last post by:
I'm trying to write an extension for python 2.4, and I can't seem to get PyArg_ParseTuple to work with a dict. I've tried all sorts of things, but the most simple thing that fails is: if (!PyArg_ParseTuple(args, "O", &file)) { return NULL; }
1
3169
by: zyqnews | last post by:
hello all, how to parse the arguments of a c function with PyArg_ParseTuple? The prototype of the c function is : int func(unsigned char * in , int inlen, unsigned char * v, unsigned char * out, int * outlen); The problem is , when the func returns, there will be results in out and outlen. Is the following format is correct? PyObject*...
162
6643
by: Richard Heathfield | last post by:
I found something interesting on the Web today, purely by chance. It would be funny if it weren't so sad. Or sad if it weren't so funny. I'm not sure which. http://www.developerdotstar.com/community/node/291 This "teacher of C" demonstrates his prowess with a masterful display of incompetence in a 200-line program that travels as...
6
2054
by: bhochstetler | last post by:
I am on a hp 11.11 machine doing a 64 bit python 2.5 build. When I get my python executable created and run it, I get the error: "import site failed" OverflowError: signed integer is greater than the maximum. This is happening in the convertsimple() routine when it tries to return a signed int:
0
1249
by: Gabriel Genellina | last post by:
En Mon, 15 Sep 2008 06:58:48 -0300, Pau Freixes <pfreixes@gmail.com> escribió: I don't understand the actual question - the example looks fine, what's your problem? Do you want to check the object types? Use PyDict_Check / PyList_Check. -- Gabriel Genellina
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.