[GHC] #11001: BlockedIndefinitelyOnMVar thrown with live reference in unrelated finalizer

#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

#11001: BlockedIndefinitelyOnMVar thrown with live reference in unrelated finalizer -------------------------------------+------------------------------------- Reporter: exFalso | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.10.2 Resolution: | Keywords: | BlockedIndefinitelyOnMVar finalize Operating System: Linux | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by osa1): * cc: osa1 (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11001#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11001: BlockedIndefinitelyOnMVar thrown with live reference in unrelated finalizer -------------------------------------+------------------------------------- Reporter: exFalso | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Runtime System | Version: 7.10.2 Resolution: wontfix | Keywords: | BlockedIndefinitelyOnMVar finalize Operating System: Linux | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonmar): * status: new => closed * resolution: => wontfix Comment: Yes, this is working as intended, see documentation at https://downloads.haskell.org/~ghc/7.10.2/docs/html/libraries/base-4.8.1.0 /Control-Concurrent.html#g:14 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11001#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC