[commit: ghc] master: base: fdReady(): Fix timeouts > ~49 days overflowing. Fixes #14262. (f209e66)
git at git.haskell.org
git at git.haskell.org
Fri Nov 24 17:03:08 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/f209e6672fe33235bd1d4c20c87894021cf3bbc8/ghc
>---------------------------------------------------------------
commit f209e6672fe33235bd1d4c20c87894021cf3bbc8
Author: Niklas Hambüchen <mail at nh2.me>
Date: Thu Nov 23 13:17:24 2017 -0500
base: fdReady(): Fix timeouts > ~49 days overflowing. Fixes #14262.
On 64-bit UNIX and Windows, Haskell `Int` has 64 bits
but C `int msecs` has 32 bits, resulting in an overflow.
This commit fixes it by switching fdReady() to take int64_t,
into which a Haskell `Int` will always fit.
(Note we could not switch to `long long` because that is
32 bit on 64-bit Windows machines.)
Further, to be able to actually wait longer than ~49 days,
we put loops around the waiting syscalls (they all accept only
32-bit integers).
Note the timer signal would typically interrupt the syscalls
before the ~49 days are over, but you can run Haskell programs
without the timer signal, an we want it to be correct in all
cases.
Reviewers: bgamari, austin, hvr, NicolasT, Phyx
Reviewed By: bgamari, Phyx
Subscribers: syd, Phyx, rwbarton, thomie
GHC Trac Issues: #14262
Differential Revision: https://phabricator.haskell.org/D4011
>---------------------------------------------------------------
f209e6672fe33235bd1d4c20c87894021cf3bbc8
libraries/base/Control/Concurrent.hs | 8 +-
libraries/base/GHC/IO/FD.hs | 4 +-
libraries/base/cbits/inputReady.c | 259 +++++++++++++++++++++++++++--------
libraries/base/include/HsBase.h | 2 +-
rts/RtsSymbols.c | 1 +
5 files changed, 212 insertions(+), 62 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc f209e6672fe33235bd1d4c20c87894021cf3bbc8
More information about the ghc-commits
mailing list