[GHC] #11001: BlockedIndefinitelyOnMVar thrown with live reference in unrelated finalizer
GHC
ghc-devs at haskell.org
Thu Oct 22 14:02:25 UTC 2015
#11001: BlockedIndefinitelyOnMVar thrown with live reference in unrelated finalizer
-------------------------------------+-------------------------------------
Reporter: exFalso | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Runtime | Version: 7.10.2
System |
Keywords: | Operating System: Linux
BlockedIndefinitelyOnMVar |
finalize |
Architecture: | Type of failure: Incorrect result
Unknown/Multiple | at runtime
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
I am not sure whether this is a bug, but it is certainly unexpected
behaviour. The following code throws a BlockedIndefinitelyOnMVar in the
forked thread even though the MVar would be eventually written to by an
unrelated finalizer:
{{{#!hs
import Control.Concurrent
import Data.IORef
main :: IO ()
main = do
mvar <- newEmptyMVar
-- _ <- forkIO $ threadDelay 9999999999999 >> isEmptyMVar mvar >> return
()
ref <- newIORef () -- unrelated IORef
_ <- mkWeakIORef ref (putMVar mvar ()) -- register finalizer
_ <- forkFinally (takeMVar mvar :: IO ()) print
threadDelay 1000000
}}}
And indeed, if the forkIO line is uncommented no exception is thrown, as
the new thread keeps another live reference to the MVar. Is this intended
behaviour? Why does the MVar reference in the finalizer not count for
BlockedIndefinitelyOnMVar?
(A similar thing happens with STM primitives.)
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11001>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list