[GHC] #8089: Implementation of GHC.Event.Poll.poll is broken due to bad coercion

GHC ghc-devs at haskell.org
Thu Jul 16 17:52:58 UTC 2015


#8089: Implementation of GHC.Event.Poll.poll is broken due to bad coercion
-------------------------------------+-------------------------------------
        Reporter:  merijn            |                   Owner:
            Type:  bug               |                  Status:  closed
        Priority:  normal            |               Milestone:  7.10.1
       Component:  libraries/base    |                 Version:  7.6.3
      Resolution:  fixed             |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  Runtime crash     |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:  Phab:D407
-------------------------------------+-------------------------------------

Comment (by thomie):

 For posterity, other commits in this series:

 * 33ed16bd8b3d95dd18e401a3d64435d8675b5f86
 {{{
 Author: Merijn Verstraaten <>
 Date:   Wed Jul 24 19:00:42 2013 +0100

     *Really* RTS crash due to bad coercion.

     Previous commit only moved the coercion mistake to a different
     architecture (i.e. underflow could still occur on platforms where Int
     is smaller than CInt). This patch should definitively deal with all
     possible combinations.

     Signed-off-by: Austin Seipp <>
 }}}

 * 00e04e81fb127d716719a85d9387a98b664b7176
 {{{
 Author: Merijn Verstraaten <>
 Date:   Wed Jul 24 14:37:25 2013 +0100

     Fix OSX RTS crash due to bad coercion.

     The code coerces Int to CInt, which causes an overflow if Int is
 bigger
     than CInt (for example, Int 64bit, CInt 32 bit). This results in a
     negative value being passed to c_poll.

     On Linux all negative values are treated as infinite timeouts, which
     gives subtly wrong semantics, but is unlikely to produce actual bugs.

     OSX insists that only -1 is a valid value for infinite timeout, any
     other negative timeout is treated as an invalid argument.

     This patch replaces the c_poll call with a loop that handles the
     overflow gracefully by chaining multiple calls to poll to obtain the
     proper semantics.

     Signed-off-by: Austin Seipp <>
 }}}

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


More information about the ghc-tickets mailing list