[SciPy-User] Wrapping a lapack function (attempt results seg fault)

Skipper Seabold jsseabold@gmail....
Sat Feb 6 14:10:26 CST 2010


All,

I'm trying to wrap the lapack function dtgsen for the ordered generalized
Schur decomposition given real valued arrays <
http://linux.die.net/man/l/dtgsen>.  However, I'm getting a segmentation
fault, and I have no idea why.  I was hoping someone might look at my work
and see where I've gone wrong, as this is my first attempt at trying to do
something like this.  One specific thing I wasn't sure about is when the
lapack function calls for a LOGICAL type can this just be

from ctypes import c_bool
logical_true = c_bool(True)

?

I've attached my functions and arrays that make a self-contained example.
 Just put the two files in a directory and run.  When I do a gdb backtrace I
receive the following output.

(gdb) run ordqztest.py

Starting program: /usr/bin/python ordqztest.py

[Thread debugging using libthread_db enabled]


Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5015d7d in dtgsen_ () from /usr/lib/liblapack.so
(gdb) backtrace
#0  0x00007ffff5015d7d in dtgsen_ () from /usr/lib/liblapack.so
#1  0x00007ffff6da8bec in ffi_call_unix64 ()
   at
/build/buildd/python2.6-2.6.4/Modules/_ctypes/libffi/src/x86/unix64.S:75
#2  0x00007ffff6da82d3 in ffi_call (cif=0x7fffffffd810, fn=<value optimized
out>,
   rvalue=<value optimized out>, avalue=<value optimized out>)

   at
/build/buildd/python2.6-2.6.4/Modules/_ctypes/libffi/src/x86/ffi64.c:430
#3  0x00007ffff6da2d64 in _call_function_pointer (pProc=<value optimized
out>,
   argtuple=<value optimized out>, flags=<value optimized out>,
argtypes=<value optimized out>,
   restype=<value optimized out>, checker=<value optimized out>)

   at /build/buildd/python2.6-2.6.4/Modules/_ctypes/callproc.c:816

#4  _CallProc (pProc=<value optimized out>, argtuple=<value optimized out>,

   flags=<value optimized out>, argtypes=<value optimized out>,
restype=<value optimized out>,
   checker=<value optimized out>) at
/build/buildd/python2.6-2.6.4/Modules/_ctypes/callproc.c:1163
#5  0x00007ffff6d9abf7 in CFuncPtr_call (self=0xc2c2c0, inargs=0x18,
kwds=<value optimized out>)
   at /build/buildd/python2.6-2.6.4/Modules/_ctypes/_ctypes.c:3860

#6  0x000000000041d6e7 in PyObject_Call (func=0xc2c2c0, arg=0xcb8360,
kw=0xc63520)
   at ../Objects/abstract.c:2492

#7  0x00000000004a199c in do_call (f=0xcb98c0, throwflag=<value optimized
out>)
   at ../Python/ceval.c:3924

#8  call_function (f=0xcb98c0, throwflag=<value optimized out>) at
../Python/ceval.c:3729
#9  PyEval_EvalFrameEx (f=0xcb98c0, throwflag=<value optimized out>) at
../Python/ceval.c:2389
#10 0x00000000004a40e0 in PyEval_EvalCodeEx (co=0x7ffff7f01f30,
globals=<value optimized out>,
   locals=<value optimized out>, args=0x9, argcount=<value optimized out>,
kws=<value optimized out>,
   kwcount=2, defs=0x7ffff7f0a7f8, defcount=4, closure=0x0) at
../Python/ceval.c:2968
#11 0x00000000004a245f in fast_function (f=0xcb9660, throwflag=<value
optimized out>)
   at ../Python/ceval.c:3802

#12 call_function (f=0xcb9660, throwflag=<value optimized out>) at
../Python/ceval.c:3727
---Type <return> to continue, or q <return> to quit---

#13 PyEval_EvalFrameEx (f=0xcb9660, throwflag=<value optimized out>) at
../Python/ceval.c:2389
#14 0x00000000004a40e0 in PyEval_EvalCodeEx (co=0x7ffff7f026c0,
globals=<value optimized out>,
   locals=<value optimized out>, args=0x8, argcount=<value optimized out>,
kws=<value optimized out>,
   kwcount=2, defs=0x7ffff3ea9e78, defcount=3, closure=0x0) at
../Python/ceval.c:2968
#15 0x00000000004a245f in fast_function (f=0x928e00, throwflag=<value
optimized out>)
   at ../Python/ceval.c:3802
#16 call_function (f=0x928e00, throwflag=<value optimized out>) at
../Python/ceval.c:3727
#17 PyEval_EvalFrameEx (f=0x928e00, throwflag=<value optimized out>) at
../Python/ceval.c:2389
#18 0x00000000004a40e0 in PyEval_EvalCodeEx (co=0x7ffff7f02378,
globals=<value optimized out>,
   locals=<value optimized out>, args=0x0, argcount=<value optimized out>,
kws=<value optimized out>,
   kwcount=0, defs=0x0, defcount=0, closure=0x0) at ../Python/ceval.c:2968
#19 0x00000000004a41b2 in PyEval_EvalCode (co=0x0, globals=0xcb8360,
locals=0xc63520)
   at ../Python/ceval.c:522
#20 0x00000000004c33a0 in run_mod (fp=0x919900, filename=<value optimized
out>,
   start=<value optimized out>, globals=<value optimized out>,
locals=0x8b9270, closeit=1,
   flags=0x7fffffffe100) at ../Python/pythonrun.c:1335
#21 PyRun_FileExFlags (fp=0x919900, filename=<value optimized out>,
start=<value optimized out>,
   globals=<value optimized out>, locals=0x8b9270, closeit=1,
flags=0x7fffffffe100)
   at ../Python/pythonrun.c:1321
#22 0x00000000004c3564 in PyRun_SimpleFileExFlags (fp=<value optimized out>,
   filename=0x7fffffffe518 "ordqztest.py", closeit=1, flags=0x7fffffffe100)
   at ../Python/pythonrun.c:931
#23 0x0000000000418ab7 in Py_Main (argc=-135384960, argv=<value optimized
out>) at ../Modules/main.c:599
#24 0x00007ffff6fd0abd in __libc_start_main (main=<value optimized out>,
argc=<value optimized out>,
   ubp_av=<value optimized out>, init=<value optimized out>, fini=<value
optimized out>,
   rtld_fini=<value optimized out>, stack_end=0x7fffffffe218) at
libc-start.c:220
#25 0x0000000000417ca9 in _start () at ../sysdeps/x86_64/elf/start.S:113

Any help or pointers would be appreciated, as I am a bit out of my depth.

-Skipper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100206/ed14f35f/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ordqztest.py
Type: text/x-python
Size: 4543 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20100206/ed14f35f/attachment-0001.py 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testvals.npz
Type: application/octet-stream
Size: 6942 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20100206/ed14f35f/attachment-0001.obj 


More information about the SciPy-User mailing list