question about debugging haskell/C using ffi

Simon Marlow simonmar at microsoft.com
Wed Nov 8 06:12:10 EST 2000


> at the moment I'm writing a haskell/C programm using the FFI. But I'm
> getting always a segfault in the haskell part (according to gdb) .

Unfortunately these really are tricky to track down.  We don't have good
debugging tools for Haskell code or the RTS at the moment.  First thing to
check is whether changing the heap size has any effect; if so, it's probably
a GC-related problem of some sort(*).

You can make a start by compiling up a debugging RTS, which enables lots of
assertions and debugging code.  Check in config.mk for the two lines you
need to add to build.mk.  Then, with your program linked against the
debugging RTS, run it with +RTS -D128 to enable GC sanity checking.  This
may or may not cause an assertion failure (unfortunately it has some false
positives at the moment).

To actually debug the Haskell code, the only way is to run gdb as if it was
debugging an assembly program - use si instead of s etc.

If you can get a repeatable crash then we'll happily take a look for you -
this will be much easier if you can package it up with a Makefile so that we
can just "unpack & go".

Cheers,
	Simon

(*) you really want the answer to this question to be "no" :-)




More information about the FFI mailing list