[GHC] #13525: hWaitForInput with timeout causes program to abort

#13525: hWaitForInput with timeout causes program to abort --------------------------------------+---------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.2 Keywords: | Operating System: Linux Architecture: x86_64 (amd64) | Type of failure: Runtime crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+---------------------------------- This program, {{{#!hs import System.IO import System.Timeout main = hWaitForInput stdin (5 * 1000) }}} causes the program to abort (tested on Linux), {{{ $ ghc hi.hs [1 of 1] Compiling Main ( hi.hs, hi.o ) Linking hi ... $ ./hi fdReady: msecs != 0, this shouldn't happenAborted }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13525 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13525: hWaitForInput with timeout causes program to abort ----------------------------------+-------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: #12912, #8684 | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by bgamari): * related: => #12912, #8684 Comment: This was originally reported as a result of #12912. #8684 is also relevant. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13525#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13525: hWaitForInput with timeout causes program to abort
----------------------------------+--------------------------------------
Reporter: bgamari | Owner: (none)
Type: bug | Status: new
Priority: high | Milestone: 8.2.1
Component: Compiler | Version: 8.0.2
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64 (amd64)
Type of failure: Runtime crash | Test Case:
Blocked By: | Blocking:
Related Tickets: #12912, #8684 | Differential Rev(s):
Wiki Page: |
----------------------------------+--------------------------------------
Comment (by Ben Gamari

#13525: hWaitForInput with timeout causes program to abort ----------------------------------+-------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.2.1 Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: #12912, #8684 | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Changes (by bgamari): * priority: high => highest -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13525#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13525: hWaitForInput with timeout causes program to abort ----------------------------------+-------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.2.1 Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: #12912, #8684 | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by bgamari): One approach to fix for the threaded runtime this would be to use `threadWaitRead` in conjunction with `System.timeout`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13525#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13525: hWaitForInput with timeout causes program to abort ----------------------------------+-------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: highest | Milestone: 8.2.1 Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: #12912, #8684 | Differential Rev(s): Wiki Page: | ----------------------------------+-------------------------------------- Comment (by bgamari): For the record, this was originally broken by f46369b8a1bf90a3bdc30f2b566c3a7e03672518. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13525#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13525: hWaitForInput with timeout causes program to abort ----------------------------------+-------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: patch Priority: highest | Milestone: 8.2.1 Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: #12912, #8684 | Differential Rev(s): Phab:D3473 Wiki Page: | ----------------------------------+-------------------------------------- Changes (by bgamari): * status: new => patch * differential: => Phab:D3473 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13525#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13525: hWaitForInput with timeout causes program to abort ----------------------------------+-------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: patch Priority: highest | Milestone: 8.2.1 Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: #12912, #8684 | Differential Rev(s): Phab:D3473 Wiki Page: | ----------------------------------+-------------------------------------- Comment (by bgamari): Merged to `master` as, In [changeset:"e5732d2a28dfb8a754ee73e124e3558222a543bb/ghc" e5732d2/ghc]: {{{ base: Fix hWaitForInput with timeout on POSIX This was previously broken (#13252) by f46369b8a1bf90a3bdc30f2b566c3a7e03672518, which ported the fdReady function from `select` to `poll` and in so doing dropping support for timeouts. Unfortunately, while `select` tells us the amount of time not slept (on Linux anyways; it turns out this is implementation dependent), `poll` does not give us this luxury. Consequently, we manually need to track time slept in this case. Unfortunately, portably measuring time is hard. Ideally we would use `clock_gettime` with the monotonic clock here, but sadly this isn't supported on most versions of Darwin. Consequently, we instead use `gettimeofday`, running the risk of system time changes messing us up. Test Plan: Validate Reviewers: simonmar, austin, hvr Reviewed By: simonmar Subscribers: rwbarton, thomie GHC Trac Issues: #13252 Differential Revision: https://phabricator.haskell.org/D3473 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13525#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13525: hWaitForInput with timeout causes program to abort ----------------------------------+-------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: merge Priority: highest | Milestone: 8.2.1 Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: #12912, #8684 | Differential Rev(s): Phab:D3473 Wiki Page: | ----------------------------------+-------------------------------------- Changes (by bgamari): * status: patch => merge Comment: Merged to `ghc-8.2` as 91c4e6b6531db59b0cd4386cf0ba8f9db35728ba. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13525#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13525: hWaitForInput with timeout causes program to abort ----------------------------------+-------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: closed Priority: highest | Milestone: 8.2.1 Component: Compiler | Version: 8.0.2 Resolution: fixed | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: #12912, #8684 | Differential Rev(s): Phab:D3473 Wiki Page: | ----------------------------------+-------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13525#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13525: hWaitForInput with timeout causes program to abort
----------------------------------+--------------------------------------
Reporter: bgamari | Owner: (none)
Type: bug | Status: closed
Priority: highest | Milestone: 8.2.1
Component: Compiler | Version: 8.0.2
Resolution: fixed | Keywords:
Operating System: Linux | Architecture: x86_64 (amd64)
Type of failure: Runtime crash | Test Case:
Blocked By: | Blocking: 8684
Related Tickets: #12912, #8684 | Differential Rev(s): Phab:D3473
Wiki Page: |
----------------------------------+--------------------------------------
Comment (by Ben Gamari
participants (1)
-
GHC