Commit 96a95f05 authored by Simon Marlow's avatar Simon Marlow

Fix missing unlockClosure() call in tryReadMVar (#9148)

parent 660c3f9d
......@@ -1786,6 +1786,7 @@ stg_tryReadMVarzh ( P_ mvar, /* :: MVar a */ )
LOCK_CLOSURE(mvar, info);
if (StgMVar_value(mvar) == stg_END_TSO_QUEUE_closure) {
unlockClosure(mvar, info);
return (0, stg_NO_FINALIZER_closure);
}
......
......@@ -78,6 +78,7 @@ test('readMVar1', normal, compile_and_run, [''])
test('readMVar2', normal, compile_and_run, [''])
test('readMVar3', normal, compile_and_run, [''])
test('tryReadMVar1', normal, compile_and_run, [''])
test('tryReadMVar2', normal, compile_and_run, [''])
test('T7970', normal, compile_and_run, [''])
......
module Main where
import Control.Concurrent
import Control.Monad
main = do
m <- newEmptyMVar
done <- newEmptyMVar
let q = 200000
forkIO (do mapM (\n -> putMVar m n) [1..q]; putMVar done ())
forkIO (do replicateM_ q $ readMVar m; putMVar done ())
forkIO (do replicateM_ q $ tryReadMVar m; putMVar done ())
forkIO (do replicateM_ q $ takeMVar m; putMVar done ())
replicateM_ 4 $ takeMVar done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment