[cffi-devel] How do I debug a memory fault?

Liam Healy lnp at healy.washington.dc.us
Wed Oct 17 02:00:26 UTC 2007


Yes, I've tried that.  The problem is that I get a backtrace like so:
(gdb) where
#0  0x0000001000159475 in ?? ()
#1  0x0000000000000010 in ?? ()
#2  0x0000000000001000 in ?? ()
#3  0x000000100015afa1 in ?? ()
#4  0x000000100015b09f in ?? ()
#5  0x0000000040000017 in ?? ()
#6  0x000000100015afa1 in ?? ()
#7  0x00000010004683a3 in ?? ()
#8  0x00002b8a3182f800 in ?? ()
#9  0x000000004000004f in ?? ()
#10 0x0000001002f32767 in ?? ()
#11 0x0000000040000017 in ?? ()
#12 0x000000100015afa1 in ?? ()
#13 0x000000004000004f in ?? ()
#14 0x0000000000000000 in ?? ()

Not very informative.  I've even tried to recompile SBCL with symbols
not stripped,  but it doesn't help.

Liam



On 10/9/07, Daniel Herring <dherring at tentpost.com> wrote:
> Have you tried attaching gdb to the lisp process?
> I spot most of my errors by setting breakpoints and looking at the actual
> function call.
>
> The session would look something like
> SHELL> ps ax | grep lisp  (or sbcl or clisp or...)
> SHELL> gdb lisp 1234 (where 1234 is the process ID)
> GDB> print gsl_odeiv_step_rk8pd
> (this should be the same value you see in lisp)
> GDB> break gsl_odeiv_step_alloc
> GDB> continue
> CL> (call-bad-cffi)
> (gdb stops lisp when it calls the function)
> GDB> print gsl_odeiv_step_type
> (this pointer's value should be the same as before)
> GDB> detach
> GDB> quit
>
> - Daniel
>
> On Tue, 9 Oct 2007, Liam Healy wrote:
>
> > James,
> >
> > I tried both
> >
> > (defvar *step-rk8pd* (cffi:foreign-symbol-pointer "gsl_odeiv_step_rk8pd"))
> >
> > and
> >
> > (cffi:defcvar ("gsl_odeiv_step_rk8pd" *step-rk8pd*) :pointer :read-only t)
> >
> > I'm not clear on what the difference is, but they both give a memory
> > fault.
> >
> > Liam
> >
> >
> >
> > On 10/9/07, James Bielman <jamesjb at haytonsystems.com> wrote:
> >> On Sun, 2007-10-07 at 13:16 -0400, Liam Healy wrote:
> >>> I am using CFFI in SBCL on Debian GNU/Linux etch (amd64).  I have had
> >>> a great deal of success interfacing to the GNU scientific library
> >>> (GSL).  Usually, when I get a "memory fault" I quickly can see my
> >>> mistake in defining the interface, and once fixed, the error goes
> >>> away.
> >>>
> >>> I can't figure this one out however.  The interface is:
> >>>   gsl_odeiv_step * gsl_odeiv_step_alloc (const gsl_odeiv_step_type *
> >>> T, size_t dim)
> >>> I attempt to call this with a predefined pointer,
> >>>   (describe *step-rk8pd*)
> >>>   #.(SB-SYS:INT-SAP #X2B31DAEB0328) is a SB-SYS:SYSTEM-AREA-POINTER.
> >>> and I get a memory fault.  What is the best way to debug this?
> >>
> >> Hi Liam,
> >>
> >> You don't show how you are defining *STEP-RK8PD* here, but I am
> >> wondering if what you actually have is the address of that variable.
> >>
> >> Are you defining this with DEFCVAR?
> >>
> >> James
> >>
> >>
> >>
> > _______________________________________________
> > cffi-devel mailing list
> > cffi-devel at common-lisp.net
> > http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel
> >
> _______________________________________________
> cffi-devel mailing list
> cffi-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel
>



More information about the cffi-devel mailing list