[GHC] #13497: GHC does not use select()/poll() correctly on non-Linux platforms

GHC ghc-devs at haskell.org
Sun Jul 30 23:23:44 UTC 2017


#13497: GHC does not use select()/poll() correctly on non-Linux platforms
-------------------------------------+-------------------------------------
        Reporter:  nh2               |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Runtime System    |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:  8684
 Related Tickets:  #8684, #12912     |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by nh2):

 Another thing I found:

 The comment on top of `fdReady()` says:

 {{{
 "Input is available" is defined as 'can I safely read at least a
 *character* from this file object without blocking?'
 }}}

 But this seems to be not true in the general case:

 If the FD is for a socket, then it is only true when that socket is non-
 blocking.

 `man 2 poll` (see [https://linux.die.net/man/2/poll here]) describes this:

 > Bugs
 >
 > See the discussion of spurious readiness notifications under the BUGS
 section of select(2).

 `man 2 select` (see [https://linux.die.net/man/2/poll here]) says:

 > Under Linux, `select()` may report a socket file descriptor as "ready
 for reading", while nevertheless a subsequent read blocks. This could for
 example happen when data has arrived but upon examination has wrong
 checksum and is discarded. There may be other circumstances in which a
 file descriptor is spuriously reported as ready. Thus it may be safer to
 use `O_NONBLOCK` on sockets that should not block.

 I have not investigated whether anywhere in GHC `fdReady()` is potentially
 called with a not-nonblocking socket.

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


More information about the ghc-tickets mailing list