threadWaitRead on mingw32 threaded causes internal error
threadWaitRead (used in 6.8.x to avoid the non-interruptable getChar) causes internal error on GHC 6.8.2 and 6.8.3:
```
prompt: test: internal error: waitRead# on threaded RTS
(GHC version 6.8.2 for i386_unknown_mingw32)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
```
This is because in GHC.Conc:
```
threadWaitRead :: Fd -> IO ()
threadWaitRead fd
#ifndef mingw32_HOST_OS
| threaded = waitForReadEvent fd
#endif
| otherwise = IO $ \s ->
case fromIntegral fd of { I# fd# ->
case waitRead# fd# s of { s -> (# s, () #)
}}
```
So the threaded case is ignored on mingw32, and waitRead\# crashes on threaded RTS.
It should be at least written on the threadWaitRead documentation, and a workaround provided.
I've attached a little program to show the issue (if compiled with -threaded on windows).
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 6.8.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"threadWaitRead on mingw32 threaded causes internal error","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.8.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"threadWaitRead (used in 6.8.x to avoid the non-interruptable getChar) causes internal error on GHC 6.8.2 and 6.8.3:\r\n\r\n{{{\r\nprompt: test: internal error: waitRead# on threaded RTS\r\n (GHC version 6.8.2 for i386_unknown_mingw32)\r\n Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n\r\nThis application has requested the Runtime to terminate it in an unusual way.\r\nPlease contact the application's support team for more information.\r\n}}}\r\n\r\nThis is because in GHC.Conc:\r\n{{{\r\nthreadWaitRead :: Fd -> IO ()\r\nthreadWaitRead fd\r\n#ifndef mingw32_HOST_OS\r\n | threaded = waitForReadEvent fd\r\n#endif\r\n | otherwise = IO $ \\s -> \r\n\tcase fromIntegral fd of { I# fd# ->\r\n\tcase waitRead# fd# s of { s -> (# s, () #)\r\n\t}}\r\n}}}\r\nSo the threaded case is ignored on mingw32, and waitRead# crashes on threaded RTS.\r\nIt should be at least written on the threadWaitRead documentation, and a workaround provided.\r\n\r\nI've attached a little program to show the issue (if compiled with -threaded on windows).","type_of_failure":"OtherFailure","blocking":[]} -->
issue