ghc 6.6 for Windows crashes my program on exit

Brian Hulley brianh at metamilk.com
Sat Oct 14 15:47:05 EDT 2006


Hi,
Has anyone else come across this crash with ghc 6.6 on Windows?

    The thread 'Win32 Thread' (0x5c8) has exited with code 0 (0x0).
    First-chance exception at 0x7c90eb74 in main.exe: 0xC0000008:
       An invalid HANDLE was specified.
    Unhandled exception at 0x7c90eb74 in main.exe: 0xC0000008:
       An invalid HANDLE was specified.

The program has this form:

    main = do
                    display_graphics_window_and_run_message_loop
                    -- window has now been closed
                    putStrLn "Finished\n"
                    getChar

and has been working perfectly with ghc 6.4.2. The only changes I had to 
make to compile it with ghc 6.6 were minor tweaks to deal with the changes 
to the ByteString api. When I run the ghc 6.6 compiled version, the window 
is displayed and works as usual, then when I dismiss the window, "Finished" 
is written to the console. It is only when I press return in the console 
that the program crashes on exit with that error message.

I'm running the program from within MS Visual Studio (the graphics window is 
written as a C DLL that's called from Haskell). If I just run the program 
directly from the desktop the program exits silently . If I run the program 
from a command shell nothing unusual happens either: no error is printed out 
but the crash-on-exit is presumably still happening.

>From just looking at the error message, it looks to me like it might be that 
the rts exit code has somehow held onto the handle of the window's thread 
after this thread no longer exists, but of course this is only a wild guess.

Alternatively, which file(s) in the ghc source distro would be the place to 
start looking to see what happens between the time the thread for the window 
has exited and the thread for main.exe exits?

Thanks, Brian.
-- 
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com 



More information about the Glasgow-haskell-users mailing list