
#7719: System.Timeout.timeout may leak <<timeout>> exceptions -------------------------+-------------------------------------------------- Reporter: int-e | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 7.7 | Keywords: Os: Linux | Architecture: x86_64 (amd64) Failure: None/Unknown | Blockedby: Blocking: | Related: -------------------------+-------------------------------------------------- Comment(by int-e): A possible scenario for two nested threads on a single capability is the following, based on the fact that {{{threadDelay}}} masks exceptions while using {{{takeMVar}}} to wait for a timeout. {{{ A = timeout n (timeout m (return ()) M = TimerManager Ti = timer threads A: outer timeout ... set up T1 A: inner timeout ... set up T2 A: threadDelay (insert into M's queue, block on MVar) T1: threadDelay (insert into M's queue, block on MVar) T2: threadDelay (insert into M's queue, block on MVar) M: process queue, performing the takeMVar for A, T1, T2 A: killThread T2 ... blocks, because T2 is now ready to run and has exceptions blocked! T1: throws TimeOut to A, which succeeds. T2: throws TimeOut to A, which is enqueued. A: catches T1 in the inner timeout, re-raises T1 to the outer timeout, completes the call. A: Now catches the pending TimeOut from T2. }}} (Examples using multiple capabilities running in parallel are easier to construct.) -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7719#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler