27 May 2012 12:08
#6126: Fix risk of dead-lock in documentation of Control.Concurrent
GHC <cvs-ghc <at> haskell.org>
2012-05-27 10:08:56 GMT
2012-05-27 10:08:56 GMT
#6126: Fix risk of dead-lock in documentation of Control.Concurrent
-------------------------------+--------------------------------------------
Reporter: basvandijk | Owner:
Type: bug | Status: new
Priority: normal | Component: libraries/base
Version: 7.4.1 | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: Documentation bug | Testcase:
Blockedby: | Blocking:
Related: |
-------------------------------+--------------------------------------------
The [http://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html
/Control-Concurrent.html#g:12 current] documentation of
`Control.Concurrent` proposes a function to wait for a child thread to
complete:
{{{
myForkIO :: IO () -> IO (MVar ())
myForkIO io = do
mvar <- newEmptyMVar
forkIO (io `finally` putMVar mvar ())
return mvar
}}}
This function has the risk of causing a dead-lock. If an asynchronous
exception if thrown before the `putMVar` exception handler is installed
the `mvar` will remain empty. This causes a dead-lock when the `mvar` is
taken.
The attached patch fixes this problem by correctly masking asynchronous
(Continue reading)
RSS Feed