Success Story: Cabal and Dlls

Simon Marlow simonmarhaskell at
Thu Jul 27 07:31:27 EDT 2006

Jason Dagit wrote:
> Perhaps I spoke too soon.
> I loaded my dll into a C++ application (where it will be used) and as
> soon as I hit FreeLibrary() my program crashes.  I tried adding
> shutdownHaskell() to the dll and it gets a little better.  It goes
> from crashing all the time to crashing some of the time.  I wrote a
> small test program in C++ where I added a 100 iteration loop that just
> loads and unloads the Dll.  It seems to crash my program usually
> before getting to the double digits.  I noticed the memory usage seems
> to climb quite a bit too.
> I found this thread:
> I don't see a solution listed there.  This is a show stopper for me.
> If I can't get Dlls working reliably then I won't be using haskell :(
> So I'm looking for just about any reasonable solution.

We do have some bugs with loading and unloading DLLs multiple times.  I believe 
I've fixed the worst bugs (the ones that cause direct crashes), but there are 
apparently some resource leakages too.

The version of GHC you have with Visual Haskell doesn't have the fixes 
unfortunately, so you would have to drop VH and use a GHC snapshot or wait until 
we can put out a new Visual Haskell (no timeframe for that as yet).

See these:

You should probably talk to Lennart Augustsson 
<lennart.augustsson at> who is using DLLs quite heavily (and 
submitted most of those bug reports).


More information about the Libraries mailing list