#4057: Modifying TVar after calling always causes freeze/spin in GHCi
---------------------------------+------------------------------------------
Reporter: Baughn | Owner:
Type: bug | Status: new
Priority: high | Milestone: 6.14.1
Component: GHCi | Version: 6.12.1
Keywords: | Difficulty:
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: Incorrect result at runtime
---------------------------------+------------------------------------------
Changes (by igloo):
* priority: normal => high
* failure: None/Unknown => Incorrect result at runtime
* milestone: => 6.14.1
Comment:
Thanks for the report.
I can reproduce this 99% of the time. Here's a version that doesn't need
anything outside of validate:
{{{
import Control.Monad
import GHC.Conc
import System.IO
modifyTVar :: TVar Integer -> (Integer -> Integer) -> STM ()
modifyTVar t f = readTVar t >>= writeTVar t . f
main :: IO ()
main = do
hSetBuffering stdout LineBuffering
t <- newTVarIO 0
let f = atomically $ do always (liftM2 (<=) (readTVar t) (return 5))
modifyTVar t succ
putStrLn "f1"
f
putStrLn "f2"
f
putStrLn "v"
v <- atomically $ readTVar t
print v
}}}
{{{
*Main> main
f1
f2
^CInterrupted.
*Main> main
f1
f2
^CInterrupted.
*Main>
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4057#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs