
#8684: hWaitForInput cannot be interrupted by async exceptions on unix -------------------------------------+------------------------------------- Reporter: nh2 | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: 13497, 13525 | Blocking: Related Tickets: #12912, #13525 | Differential Rev(s): Phab:D42 Wiki Page: | -------------------------------------+------------------------------------- Comment (by nh2): OK new info with the power of `-debug` and `+RTS -Ds`: In non`-threaded`, it does raise the exception, but _after_ the entire `hWaitForInput` is over. I can see it in `cap 0: raising exception in thread 2.`, and also the reason: `timeout`'s `throwTo ` also only happens **after** `hWaitForInput` is over (it prints `cap 0: throwTo: from thread 1 to thread 2` only at the very end). So that means it's not the exception handling that's not working, it's the throwing. My C code returns back into Haskell land, but there is no exception there at the time so it continues. ---- On my debug commit https://github.com/nh2/ghc/blob/49a5e9ce7062da7594bfd86ca7af92796b84b52a/lib... that looks like this (relevant output without `-debug` in [https://gist.github.com/nh2/f543030a9b68b1530b19087d0c655115 this gist]): {{{ cap 0: running thread 1 (ThreadRunGHC) cap 0: thread 1 stopped (suspended while making a foreign call) fdReady called with msecs = 20 fdReady res = -1 cap 0: running thread 1 (ThreadRunGHC) cap 0: thread 1 stopped (suspended while making a foreign call) fdReady called with msecs = 10 fdReady res = -1 cap 0: running thread 1 (ThreadRunGHC) cap 0: thread 1 stopped (suspended while making a foreign call) fdReady called with msecs = 0 fdReady res = 0 cap 0: running thread 1 (ThreadRunGHC) cap 0: throwTo: from thread 1 to thread 2 thread 2 @ 0x42001059d0 is blocked until 558048911098409 (TSO_DIRTY) cap 0: raising exception in thread 2. cap 0: thread 1 stopped (finished) bound thread (1) finished task exiting }}} Observe here how `cap 0: throwTo: from thread 1 to thread 2` is after the `fdReady called with msecs = 0` (`hWaitForInput` ran its entire 5 seconds). ---- So now we just need to find out why `timeout` doesn't result in a prompt `cap 0: throwTo: from thread 1 to thread 2` after 1 second. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8684#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler