Martin Kowalczyk writes:

> $ ghc -fglasgow-exts -c Crash.hs
> $ ghc -c crash.c
> $ ghc -fglasgow-exts Crash.o Crash_stub.o crash.o -o crash
> $ ./crash
> 1000000000000000000000000000003000000000000000000000000000002
> zsh: segmentation fault  ./crash
> $ ghc --version
> The Glorious Glasgow Haskell Compilation System, version 4.06

I've diagnosed this, and it turns out to be due to the garbage collector
prematurely collecting the foreign exported functions, or things they depend
on.

In this case, you can work around the problem in two ways: either compile
the module with -O, which specialises the overloading and eliminates the
offending CAFs (not guaranteed to always work, of course...), or explicitly
make a StablePtr for each of the things you export.  I've verified that this
works on your example.

We'll hopefully get around to fixing this properly before the next release -
there's a note on our whiteboard at least :)

Cheers,
        Simon

Reply via email to