[ python-Bugs-1229788 ] Bus error in extension with gcc 3.3
SourceForge.net
noreply at sourceforge.net
Wed Jun 29 17:43:13 CEST 2005
Bugs item #1229788, was opened at 2005-06-29 11:43
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1229788&group_id=5470
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
python.
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 *
fun0()
411.0
>>> fun1()
534.30000000000007
>>> fun2()
411.0
>>> 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
some
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
by
1.3"},
{"fun2", fun2, METH_VARARGS, "Return value using
PyFloat_FromDouble"},
{"fun3", fun3, METH_VARARGS, "Return value using
Py_BuildValue
without reading args -- causes bus error on OS X Panther with
XCode 1.5
installed"},
{NULL, NULL, 0, NULL} /* Sentinel */
};
PyMODINIT_FUNC
initcheck(void)
{
PyObject *module;
module = Py_InitModule3("check", TestMethods,
"extension module with three functions.");
if (module) {
PyModule_AddStringConstant(module, "__version__", "0.02");
}
}
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1229788&group_id=5470
More information about the Python-bugs-list
mailing list