System.Timeout.timeout may leak <<timeout>> exceptions
The current implementation of timeout can leak Timeout exceptions if an asynchronous exception is delivered at the wrong time. The most worrysome such case is another Timeout exception raised by surrounding call to timeout. The following program reproduces the issue reliably for me:
import System.Timeout
import Control.Monad
import Control.Concurrent
t d = timeout d $ timeout d $ timeout d $ timeout d $ timeout d $ timeout (10^9) $ threadDelay 100
main = forever $ mapM_ t [1..200]
-- > ghc -O2 -rtsopts -threaded --make TT.hs
-- > ./TT +RTS -N1
-- TT: <<timeout>>
Context: A recent thread on ghc-users, starting with http://www.haskell.org/pipermail/glasgow-haskell-users/2013-February/023811.html, got me thinking about corner cases of timeout handling again.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/base |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |