[ python-Bugs-1229788 ] Bus error in extension with gcc 3.3

SourceForge.net noreply at sourceforge.net
Thu Jun 30 22:15:26 CEST 2005

Bugs item #1229788, was opened at 2005-06-29 11:43
Message generated for change (Comment added) made by garyrob
You can respond by visiting: 

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Gary Robinson (garyrob)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bus error in extension with gcc 3.3

Initial Comment:
This text contains a c module with 4 versions of the same 
extremely simple function. All they do is return a float double to 

On Windows I have received a report from someone who can built 
the module, imported it into Python, and ran it successfully. 

It has also been reported that there is no problem when the 
extension is compiled with gcc 4.0 on OS X.

However, on OS X, if the extension is compiled with gcc 3.3, the 4th 
of the 4 function results in a bus error:

>>> from check import *
>>> fun1()
>>> fun2()
>>> fun3()
Bus error

I originally reported this on the C++ sig's mail list. They suggested I 
try dev-python. Scott David Daniels on that list helped me refine 
test cases and verified that they all worked on Windows. 

Along the way it was suggested that I post a bug report. So this is it.

The code follows:

#include "Python.h"
static double value = 411.0;

static PyObject *
fun0(PyObject *self, PyObject *args)
    if (!PyArg_ParseTuple(args, "", NULL)) return NULL;
    return Py_BuildValue("d", value);

static PyObject *
fun1(PyObject *self, PyObject *args)
    return Py_BuildValue("d", 1.3*value);

static PyObject *
fun2(PyObject *self, PyObject *args)
    return PyFloat_FromDouble(value);

static PyObject *
fun3(PyObject *self, PyObject *args)
    return Py_BuildValue("d", value);

static PyMethodDef TestMethods[] = {
    {"fun0", fun0, METH_VARARGS, "Read args and return value"},
    {"fun1", fun1, METH_VARARGS, "Return value multiplied inline 
    {"fun2", fun2, METH_VARARGS, "Return value using 
    {"fun3", fun3, METH_VARARGS, "Return value using 
without reading args -- causes bus error on OS X Panther with 
XCode 1.5 
    {NULL, NULL, 0, NULL}        /* Sentinel */

    PyObject *module;

    module = Py_InitModule3("check", TestMethods,
		"extension module with three functions.");
    if (module) {
	PyModule_AddStringConstant(module, "__version__", "0.02");


>Comment By: Gary Robinson (garyrob)
Date: 2005-06-30 16:15

Logged In: YES 

It was reproduced by someone with Python 2.4 and gcc 3.3. So it is not 
my machine.

As to closing it, a couple of people in the python C++ sig and python-dev 
suggested I post it here as a bug, so I did. I'm just doing what was 
requested of me. I don't mind if someone else feels it should be closed 
without doing anything about it, but I don't think everyone would agree with 
that action.

As for stack trace, I don't know how to look for that. All I got was the "bus 
error" message. If you tell me what to look for I'll look for it. 


Comment By: Terry J. Reedy (tjreedy)
Date: 2005-06-30 16:05

Logged In: YES 

Do you have any reason to think the bug is in Python rather than 
the older version of gcc?  Or OSX?  Or even your computer?

If not, please consider closing.

Does OSX give you a stack trace?  If so,what is executing when 
the crash occurs?  In fun3, Py_BuildValue, or somehow 


You can respond by visiting: 

More information about the Python-bugs-list mailing list