[Numpy-discussion] Floating point exception with numpy and embedded python interpreter

Andrew Straw strawman at astraw.com
Wed Apr 19 10:38:11 CDT 2006

Arkaitz Bitorika wrote:

> Hi,
> I'm embedding Python in a big C++ program (the NS network simulator)
> and I have problems when importing the numpy module, I get a Floating
> Point exception. The C code that causes the exception is:

I guess you mean a CPU/kernel level floating point exception (SIGFPE),
not a Python exception?

>     Py_Initialize();
>     PyObject* module = PyImport_ImportModule("numpy");
>     Py_DECREF(module);
> I'm running Ubuntu Breezy on a dual processor Dell machine, with the
> stock python and numpy 0.9.6. One strange thing is that I haven't been
> able to reproduce the crash by writing a minimal C program with the
> code above, it only crashes when added to my program. 

Does your program change error bits on the FPU or SSE units on your
processor? (What processor are you using?)

> I've been embedding Python for ages on the same program and other
> modules work fine, only numpy fails.

Most other modules don't use the SSE units, so wouldn't get hit by such
a bug.

> I've debugged the issue a bit and I've seen that the exception is
> thrown when the numpy __init__.py tries to import the core module. The
> GDB backtrace is pasted at the end.
> Any idea what may be going wrong?

glibc 2.3.2 (e.g. in debian sarge) has a bug where the SSE unit has an
error bit set wrong. But I'd guess Ubuntu isn't using this version of
glibc, so I think the problem may be elsewhere.

More information about the Numpy-discussion mailing list