[SciPy-dev] Segmentation fault triggered by optimize/lbfgsb.py
oliphant at ee.byu.edu
Tue Oct 25 22:51:54 CDT 2005
Ed Schofield wrote:
>The code in optimize/lbfgsb.py raises an exception and then dumps core:
>Traceback (most recent call last):
>line 182, in fmin_l_bfgs_b
> isave, dsave)
>ValueError: string_from_pyobj failed in converting 14th argument `csave'
>of _lbfgsb.setulb to C string
>Segmentation fault (core dumped)
>What is interesting is that I can get a segfault with the same backtrace
>even *before* the call to the Fortran function, just by executing some
>of the statements up to line 182 and exiting the python interpreter with
>^D, implying that the interpreter is no longer in a stable state.
># scipy.base.__version__ gives '0.4.3.1343'
>>>>task = scipy.zeros((60,), scipy.Character)
>>>>task[:] = 'blah'
>Here's a backtrace from gdb:
>#0 0x080de87d in Py_GetPath ()
>#1 0x08087860 in PyTuple_Pack ()
>#2 0x080df0c0 in _PyObject_GC_Track ()
>#3 0x080df897 in PyGC_Collect ()
>#4 0x080d88f9 in Py_Finalize ()
>#5 0x080556f0 in Py_Main ()
>#6 0x4938dea2 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6
>#7 0x08054f21 in _start ()
>Anyone want to take the baton? ;)
One part of the problem has been fixed in new scipy core.
Now, f2py may need to change to handle character arrays differently.
Character arrays work a little differently than they used to. Before
they were just special-cases of UBYTE arrays. Now, character arrays are
arrays of strings. Thus, the lbfgsb.py code should use
task = zeros(1, 'S60') so that
task[:] = 'blah' will do the right thing.
task = zeros(1,Character) is equivalent to
task = zeros(1,'S1')
task[:] = 'blah' is the same as
task[:] = array('blah','S1')
which fills the array with 'b'
More information about the Scipy-dev