Dll's freeze with -threaded
Attached are two source files (one .c, one .hs), which are compiled (using mk.sh) into DsoHsDemo.dll. When this library is loaded, using the following C snippet:
```
int main(int argc, char* argv[])
{
printf("Started LoadLibrary\n");
LoadLibrary("DsoHsDemo.dll");
printf("Finished LoadLibrary\n");
}
```
The program freezes:
```
$ ./mk.sh && ./CSnippet
The Glorious Glasgow Haskell Compilation System, version 6.12.0.20091010
Creating library file: DsoHsDemo.dll.a
Started LoadLibrary
pre hs_init
<program freezes>
```
The freeze only occurs when the dll is linked with -threaded, and happens within either startupHaskell, or (if you call hs_init/hs_add_root instead) within hs_add_root. This happens with GHC 6.10.4 and 6.12rc1 on Windows XP.
This bug appears to make it impossible to successfully build a DLL for multithreaded use.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | -------------------- |
| Version | 6.12.1 RC1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | ndmitchell@gmail.com |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Dll's freeze with -threaded","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.12.1 RC1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["ndmitchell@gmail.com"],"type":"Bug","description":"Attached are two source files (one .c, one .hs), which are compiled (using mk.sh) into DsoHsDemo.dll. When this library is loaded, using the following C snippet:\r\n\r\n{{{\r\nint main(int argc, char* argv[])\r\n{\r\n printf(\"Started LoadLibrary\\n\");\r\n LoadLibrary(\"DsoHsDemo.dll\");\r\n printf(\"Finished LoadLibrary\\n\");\r\n}\r\n}}}\r\n\r\nThe program freezes:\r\n\r\n{{{\r\n$ ./mk.sh && ./CSnippet\r\nThe Glorious Glasgow Haskell Compilation System, version 6.12.0.20091010\r\nCreating library file: DsoHsDemo.dll.a\r\nStarted LoadLibrary\r\npre hs_init\r\n<program freezes>\r\n}}}\r\n\r\nThe freeze only occurs when the dll is linked with -threaded, and happens within either startupHaskell, or (if you call hs_init/hs_add_root instead) within hs_add_root. This happens with GHC 6.10.4 and 6.12rc1 on Windows XP.\r\n\r\nThis bug appears to make it impossible to successfully build a DLL for multithreaded use.","type_of_failure":"OtherFailure","blocking":[]} -->
issue