reading/writing blocking FDs over FD_SETSIZE is broken
In GHC.IO.FD when reading from or writing to a blocking FD we first check (using our C function fdReady) whether the underlying fd is ready for read/write, in an attempt to avoid blocking the current OS thread. On POSIX this check is done using select, with no test for whether the fd exceeds FD_SETSIZE, causing a write out of bounds and various bad consequences.
Also, while readRawBufferPtr checks the error status of fdReady, readRawBufferPtrNoBlock, writeRawBufferPtr, writeRawBufferPtrNoBlock do not, making this issue harder to diagnose.
I suggest that fdReady use poll(2) where available. I can prepare a set of patches if needed.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/base |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | ekmett, hvr |
| Operating system | |
| Architecture |