[cffi-devel] How do I debug a memory fault?
Daniel Herring
dherring at tentpost.com
Wed Oct 10 01:54:44 UTC 2007
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
>
More information about the cffi-devel
mailing list