[GHC] #9168: reading/writing blocking FDs over FD_SETSIZE is broken

GHC ghc-devs at haskell.org
Wed Jun 4 22:43:10 UTC 2014


#9168: reading/writing blocking FDs over FD_SETSIZE is broken
------------------------------------+-------------------------------------
       Reporter:  rwbarton          |             Owner:
           Type:  bug               |            Status:  new
       Priority:  normal            |         Milestone:
      Component:  libraries/base    |           Version:  7.8.1
       Keywords:                    |  Operating System:  Unknown/Multiple
   Architecture:  Unknown/Multiple  |   Type of failure:  None/Unknown
     Difficulty:  Unknown           |         Test Case:
     Blocked By:                    |          Blocking:
Related Tickets:                    |
------------------------------------+-------------------------------------
 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.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9168>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list