#7493: STM and TVar report incorrect results
------------------------------------------+---------------------------------
Reporter: parcs | Owner:
Type: bug | Status: new
Priority: highest | Milestone: 7.6.2
Component: Runtime System | Version: 7.6.1
Resolution: | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: Incorrect result at runtime | Difficulty: Unknown
Testcase: | Blockedby:
Blocking: | Related:
------------------------------------------+---------------------------------
Comment(by fryguybob):
I've reduced the first program to the following:
{{{
import Control.Concurrent.STM
main = do
x <- atomically $ do
r <- newTVar []
writeTVar r [2]
writeTVar r [] `orElse` return ()
readTVar r
print x
}}}
This outputs `[2]` when I would expect `[]`. If I use `Int`s it does not
fail and if I have different values for each of the write or new's it
works:
{{{
import Control.Concurrent.STM
main = do
x <- atomically $ do
r <- newTVar [1]
writeTVar r [2]
writeTVar r [1] `orElse` return ()
readTVar r
print x
}}}
Outputs: `[1]`
{{{
import Control.Concurrent.STM
main = do
x <- atomically $ do
r <- newTVar 1
writeTVar r 2
writeTVar r 1 `orElse` return ()
readTVar r
print x
}}}
Output: `1`
Also interesting:
{{{
import Control.Concurrent.STM
main = do
x <- atomically $ do
r <- newTVar Nothing
writeTVar r (Just 2)
writeTVar r Nothing `orElse` return ()
readTVar r
print x
}}}
Output: `Just 2`
I'll start digging around to see what is going on with this example.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7493#comment:6>
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