[cffi-devel] Your approach to debug CFFI problems (segfaults)

dherring at tentpost.com dherring at tentpost.com
Thu Jul 26 22:26:59 UTC 2007


> Hello together,
>
> I am trying to get running the cl-alleg library:
> http://cl-alleg.sourceforge.net/
>
> But in cmucl, sbcl and clisp I either get segfaults or cause the abort
> handler to be called.

To debug segfaults, I generally fire up gdb.  Since SBCL (and maybe the
others) internally uses many things which gdb likes to catch, its good to
"detach" gdb whenever you're not using it.

My workflow looks like this:
("L:" is a lisp prompt, ">" is a bash shell prompt)
L: (defun bad-cffi () ... )
L: (bad-cffi)
... segfault detected, abort
> ps ax | grep sbcl
... shows pid 1553
> gdb sbcl 1553
... lots of stuff loads
gdb> c
... (short for 'continue' letting sbcl run)
L: (bad-cffi)
... lisp hangs at the segfault (which is caught by gdb)
gdb> bt full
... look at what's going on
gdb> detach
L: (defun better-cffi () ... )
gdb> attach 1553
L: (better-cffi)
...

Hope that helps,
Daniel





More information about the cffi-devel mailing list