GHC 6.4.1 and Win32 DLLs: Bug in shutdownHaskell?

SevenThunders mattcbro at
Tue Oct 24 14:00:06 EDT 2006

Michael Marte wrote:
> I am still using ghc 6.4.2 for creating my DLL and, as long as the DLL 
> does not open a file, releasing the DLL works fine. I have not yet tried 
> ghc 6.5.
> Michael

I just tried it under GHC 6.6 with the same results. If the DLL is loaded it
crashes when it's unloaded even if no Haskell code is actually executed. 
Again I am calling this from Matlab 6.5 so I have no idea how Matlab is
handling the loading and unloading of the DLL or what it is doing to the
environment.  All that is clear is that if the code needs to be linked to
the Haskell DLL, the phenomenon occurs.

  My DLL main program was lifted from the documentation and looks like this.

#include <windows.h>
#include <Rts.h>

extern void __stginit_ExternLib(void);

static char* args[] = { "ghcDll", NULL };
                       /* N.B. argv arrays must end with NULL */
   ( HANDLE hModule
   , DWORD reason
   , void* reserved
  if (reason == DLL_PROCESS_ATTACH) {
      /* By now, the RTS DLL should have been hoisted in, but we need to
start it up. */
      startupHaskell(1, args, __stginit_ExternLib);
      return TRUE;
  return TRUE;

ExternLib.hs is the external Haskell program that I link to but I don't
actually call.  I could probably generate a simple example of the problem,
which perhaps I shall do and post shortly.

View this message in context:
Sent from the Haskell - Glasgow-haskell-users mailing list archive at

More information about the Glasgow-haskell-users mailing list