Error in shutdownHaskell() in Win32 DLL
If an exception occurs in a Windows DLL produced by GHC, the following error message appears:
ghcDll: internal error: too many hs_exit()s
Please report this as a bug to glasgow-haskell-bugs@haskell.org,
or http://www.sourceforge.net/projects/ghc/
How to reproduce
- Make a Haskell DLL using the enclosed Dll.hs and dllMain.c, e.g.
ghc -c Dll.hs -fglasgow-exts
ghc -c dllMain.c
ghc --mk-dll -o test.dll Dll.o Dll_stub.o dllMain.o
- Generate an export library for the DLL, e.g.
lib /DEF:test.def /MACHINE:x86 /OUT:test.lib
- Compile the executable with Visual C++ and run it.
cl -c testdll.cpp
link testdll.obj test.lib /OUT:testdll.exe
testdll.exe
Note: if I comment out the shutdownHaskell() call from dllMain.c (the line marked with /***/), it works fine.
Kind regards,
Cyril
--- Dll.hs ---
module Dll (test) where
foreign export ccall test :: IO ()
test = error "Exception occurred"
--- dllMain.c ---
#include <windows.h>
#include <Rts.h>
extern void __stginit_Dll(void);
static char* args[] = { "ghcDll", NULL };
BOOL
STDCALL
DllMain
( HANDLE hModule
, DWORD reason
, void* reserved
)
{
if (reason == DLL_PROCESS_ATTACH) {
startupHaskell(1, args, __stginit_Dll);
return TRUE;
} else if (reason == DLL_PROCESS_DETACH) {
/***/ shutdownHaskell();
}
return TRUE;
}
--- test.def ---
EXPORTS
test
--- testdll.cpp ---
extern "C" void test();
int main() {
test();
return 0;
}
Trac metadata
Trac field | Value |
---|---|
Version | 6.4.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Runtime System |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture | Unknown |