Fix OSX RTS crash due to bad coercion.

Authored by merijn on Jul 24 2013, 8:37 AM.

Description

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 <aseipp@pobox.com>

Details

Committed
austinNov 7 2013, 4:11 AM
Pushed
bgamariAug 25 2016, 1:39 PM
Parents
rGHCDIFF2e7383763b22: Add Ord instances for GHC.Generics (#7263)
Branches
Unknown
Tags
Unknown