Repository navigation
Closed
Milestone
Description
Original ticket http://projects.scipy.org/numpy/ticket/1148 on 2009-06-25 by trac user hugh, assigned to unknown.
I was getting seg faults when the l_bfgs_b optimiser (fortran code) in SciPy ran and discovered this ONLY occurred when the library openbabel was loaded. The backtrace seems to suggest that the error is in numpy/core/multiarray.so.
The following code induces the crash:
import openbabel # comment out this line to stop seg fault
import numpy
from scipy.optimize.lbfgsb import fmin_l_bfgs_b
def f(x):
return x[0]**2 + x[1]**2
def g(x):
return numpy.array([2*x[0], 2*x[1]])
x0 = numpy.array([3,1])
opt, energy, dict = fmin_l_bfgs_b(f, x0, fprime=g)
print opt
Here is the backtrace:
(gdb) bt
#0 0x00007f93e8635720 in PyArray_API () from /usr/local/lib64/python2.5/site-packages/numpy/core/multiarray.so
#1 0x00007f93e435afa3 in initminpack2 () at /usr/local/lib64/python2.5/site-packages/numpy/core/include/numpy/__multiarray_api.h:983
#2 0x00007f93ea23e2f6 in _PyImport_LoadDynamicModule () from /usr/lib64/libpython2.5.so.1.0
#3 0x00007f93ea23c6e9 in ?? () from /usr/lib64/libpython2.5.so.1.0
#4 0x00007f93ea23cc79 in ?? () from /usr/lib64/libpython2.5.so.1.0
#5 0x00007f93ea23d200 in ?? () from /usr/lib64/libpython2.5.so.1.0
#6 0x00007f93ea23d335 in PyImport_ImportModuleLevel () from /usr/lib64/libpython2.5.so.1.0
#7 0x00007f93ea221c5d in ?? () from /usr/lib64/libpython2.5.so.1.0
#8 0x00007f93ea1ab683 in PyObject_Call () from /usr/lib64/libpython2.5.so.1.0
#9 0x00007f93ea222251 in PyEval_CallObjectWithKeywords () from /usr/lib64/libpython2.5.so.1.0
#10 0x00007f93ea226278 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.5.so.1.0
#11 0x00007f93ea229c4d in PyEval_EvalCodeEx () from /usr/lib64/libpython2.5.so.1.0
#12 0x00007f93ea229e42 in PyEval_EvalCode () from /usr/lib64/libpython2.5.so.1.0
#13 0x00007f93ea23ada0 in PyImport_ExecCodeModuleEx () from /usr/lib64/libpython2.5.so.1.0
#14 0x00007f93ea23b028 in ?? () from /usr/lib64/libpython2.5.so.1.0
#15 0x00007f93ea23c6e9 in ?? () from /usr/lib64/libpython2.5.so.1.0
#16 0x00007f93ea23c982 in ?? () from /usr/lib64/libpython2.5.so.1.0
#17 0x00007f93ea23cfcf in ?? () from /usr/lib64/libpython2.5.so.1.0
#18 0x00007f93ea23d335 in PyImport_ImportModuleLevel () from /usr/lib64/libpython2.5.so.1.0
#19 0x00007f93ea221c5d in ?? () from /usr/lib64/libpython2.5.so.1.0
#20 0x00007f93ea1ab683 in PyObject_Call () from /usr/lib64/libpython2.5.so.1.0
#21 0x00007f93ea222251 in PyEval_CallObjectWithKeywords () from /usr/lib64/libpython2.5.so.1.0
#22 0x00007f93ea226278 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.5.so.1.0
#23 0x00007f93ea229c4d in PyEval_EvalCodeEx () from /usr/lib64/libpython2.5.so.1.0
#24 0x00007f93ea229e42 in PyEval_EvalCode () from /usr/lib64/libpython2.5.so.1.0
#25 0x00007f93ea23ada0 in PyImport_ExecCodeModuleEx () from /usr/lib64/libpython2.5.so.1.0
#26 0x00007f93ea23b028 in ?? () from /usr/lib64/libpython2.5.so.1.0
#27 0x00007f93ea23c6e9 in ?? () from /usr/lib64/libpython2.5.so.1.0
#28 0x00007f93ea23c982 in ?? () from /usr/lib64/libpython2.5.so.1.0
#29 0x00007f93ea23cfcf in ?? () from /usr/lib64/libpython2.5.so.1.0
#30 0x00007f93ea23d335 in PyImport_ImportModuleLevel () from /usr/lib64/libpython2.5.so.1.0
#31 0x00007f93ea221c5d in ?? () from /usr/lib64/libpython2.5.so.1.0
#32 0x00007f93ea1ab683 in PyObject_Call () from /usr/lib64/libpython2.5.so.1.0
#33 0x00007f93ea222251 in PyEval_CallObjectWithKeywords () from /usr/lib64/libpython2.5.so.1.0
#34 0x00007f93ea226278 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.5.so.1.0
#35 0x00007f93ea229c4d in PyEval_EvalCodeEx () from /usr/lib64/libpython2.5.so.1.0
#36 0x00007f93ea229e42 in PyEval_EvalCode () from /usr/lib64/libpython2.5.so.1.0
#37 0x00007f93ea23ada0 in PyImport_ExecCodeModuleEx () from /usr/lib64/libpython2.5.so.1.0
#38 0x00007f93ea23b028 in ?? () from /usr/lib64/libpython2.5.so.1.0
#39 0x00007f93ea23bfa7 in ?? () from /usr/lib64/libpython2.5.so.1.0
#40 0x00007f93ea23c6e9 in ?? () from /usr/lib64/libpython2.5.so.1.0
#41 0x00007f93ea23c982 in ?? () from /usr/lib64/libpython2.5.so.1.0
#42 0x00007f93ea23d016 in ?? () from /usr/lib64/libpython2.5.so.1.0
#43 0x00007f93ea23d335 in PyImport_ImportModuleLevel () from /usr/lib64/libpython2.5.so.1.0
#44 0x00007f93ea221c5d in ?? () from /usr/lib64/libpython2.5.so.1.0
#45 0x00007f93ea1ab683 in PyObject_Call () from /usr/lib64/libpython2.5.so.1.0
#46 0x00007f93ea222251 in PyEval_CallObjectWithKeywords () from /usr/lib64/libpython2.5.so.1.0
#47 0x00007f93ea226278 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.5.so.1.0
#48 0x00007f93ea229c4d in PyEval_EvalCodeEx () from /usr/lib64/libpython2.5.so.1.0
#49 0x00007f93ea229e42 in PyEval_EvalCode () from /usr/lib64/libpython2.5.so.1.0
#50 0x00007f93ea23ada0 in PyImport_ExecCodeModuleEx () from /usr/lib64/libpython2.5.so.1.0
#51 0x00007f93ea23b028 in ?? () from /usr/lib64/libpython2.5.so.1.0
#52 0x00007f93ea23c6e9 in ?? () from /usr/lib64/libpython2.5.so.1.0
#53 0x00007f93ea23c982 in ?? () from /usr/lib64/libpython2.5.so.1.0
#54 0x00007f93ea23cfcf in ?? () from /usr/lib64/libpython2.5.so.1.0
#55 0x00007f93ea23d335 in PyImport_ImportModuleLevel () from /usr/lib64/libpython2.5.so.1.0
#56 0x00007f93ea221c5d in ?? () from /usr/lib64/libpython2.5.so.1.0
#57 0x00007f93ea1ab683 in PyObject_Call () from /usr/lib64/libpython2.5.so.1.0
#58 0x00007f93ea222251 in PyEval_CallObjectWithKeywords () from /usr/lib64/libpython2.5.so.1.0
#59 0x00007f93ea226278 in PyEval_EvalFrameEx () from /usr/lib64/libpython2.5.so.1.0
#60 0x00007f93ea229c4d in PyEval_EvalCodeEx () from /usr/lib64/libpython2.5.so.1.0
---Type <return> to continue, or q <return> to quit---
#61 0x00007f93ea229e42 in PyEval_EvalCode () from /usr/lib64/libpython2.5.so.1.0
#62 0x00007f93ea2447a1 in ?? () from /usr/lib64/libpython2.5.so.1.0
#63 0x00007f93ea24499c in PyRun_StringFlags () from /usr/lib64/libpython2.5.so.1.0
#64 0x00007f93ea245c10 in PyRun_SimpleStringFlags () from /usr/lib64/libpython2.5.so.1.0
#65 0x00007f93ea24f06a in Py_Main () from /usr/lib64/libpython2.5.so.1.0
#66 0x00007f93e95b8436 in __libc_start_main () from /lib64/libc.so.6
#67 0x00000000004006c9 in _start ()
Activity
thouis commentedon Oct 19, 2012
@pv wrote on 2009-07-13
The problem seems to be due to f2py.
Minimal example:
If the
#define PY_ARRAY_UNIQUE_SYMBOL PyArray_APIis left out, there is no crash. What it does, is making the PyArray_API symbol public, cf.objdump -T foo.so:Apparently, this is needed for
fortranobject.oto access the symbols?Openbabel Python bindings call
Obviously, this will causes problems down the stream, as symbols of subsequently loaded libraries are no longer isolated...
You can also reproduce the crash without Openbabel,
This behavior of Openbabel's is highly suspect IMHO. If it needs to enable this flag, it probably ought to also restore its value after loading whatever needs loading.
I think you should bring this issue up with Openbabel developers, as it doesn't look like this is a real bug in Numpy or Scipy.
thouis commentedon Oct 19, 2012
Milestone changed to
1.4.0by @pv on 2009-07-13thouis commentedon Oct 19, 2012
Title changed from
l_bfgs_b optimiser seg faults in numpy/core/multiarray.so if library openbabel is loadedtof2py modules crash if RTLD_GLOBAL in effectby @pv on 2009-07-13thouis commentedon Oct 19, 2012
@pv wrote on 2009-07-13
Closing as wontfix, as I believe the problem is in Openbabel.
Reopen if Openbabel developers disagree, or there is strong evidence that we ought not rely on RTLD_GLOBAL not being enabled.