question about debugging haskell/C using ffi

Manuel M. T. Chakravarty chak at
Thu Nov 9 02:18:19 EST 2000

Axel Krauth <krauth at> wrote,

> 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) .
> With Linux the segfault happens at random (while I'm doing a lot of calls
> to haskell via a dynamically exported function). With Unix gdb says it
> occurs in 'StgReturn' called from 'stg_returnToStackTop' after the C part
> finishes it job. 
> I already put a C frontend instead of the haskell part and
> searched for access violations and other memory missmanagement in the C
> part (none). I also disabled (with no effect) all finalizers of the
> ForeignObj's used. 
> As I'm relatively new to Haskell I don't know how to hunt that one down.
> Unfortunately the programm is already huge (ca. 4000 LOC Haskell & C) so
> the buggy part of the programm is not obvious (for me).
> Could someone give me a hint/technique how to approach the problem?

As SimonM already said, there is *unfortunately* not much in
the way of real support for hunting down such bugs.  Did you
try linking with Electric Fence (see `man efence' on your
Linux box)?  This may force the bug to occur earlier, which
might make it easier to track down.  Are you using the
`Concurrent' module?


More information about the FFI mailing list