
#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, looking at the definition of `timeout` [http://hackage.haskell.org/package/base-4.10.0.0/docs/src/System.Timeout.htm... here], and making an instrumented copy of it into my test case file, it seems that the `threadDelay n >> throwTo pid ex` is never executed. The `cap 0: throwTo: from thread 1 to thread 2` I observe at the very end is from `killThread`. Changing it into this {{{ handleJust (\e -> if e == ex then Just () else Nothing) (\_ -> return Nothing) (bracket (forkIOWithUnmask $ \unmask -> do putStrLn "before unmask" unmask $ putStrLn "before delay" >> threadDelay n >> putStrLn "delay over" >> throwTo pid ex) (\x -> putStrLn "before killThread" >> uninterruptibleMask_ (killThread x)) (\_ -> fmap Just f)) }}} yields the output at the very end: {{{ fdReady called with msecs = 0 fdReady res = 1 before killThread fdReady called with msecs = 0 fdReady res = 1 before unmask }}} and then the program terminates. This suggests that nothing inside `unmask` is ever executed in my non- threaded case, and that the thread started with `forkIOWithUnmask` doesn't actually run until `hWaitForInput` is over. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8684#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler