[GHC] #9965: getChanContents BlockedIndefinitelyOnMVar on 7.10 RC1

#9965: getChanContents BlockedIndefinitelyOnMVar on 7.10 RC1 -------------------------------------+------------------------------------- Reporter: jberryman | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: | Version: 7.10.1-rc1 libraries/base | Operating System: Unknown/Multiple Keywords: | Type of failure: Incorrect result Architecture: | at runtime Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- All of the stanzas work on 7.8.3, but the middle one works incorrectly on 7.10: {{{#!hs module Main where import Control.Concurrent.Chan import Control.Monad main = do io <- newChan let inp = [0] :: [Int] mapM_ (writeChan io) inp {- -- WORKS: outp <- getChanContents io if 0 == head outp then putStrLn "OK" else error $ "Smoke test failed" -} -- BROKEN ON 7.10 (BlockedIndefinitelyOnMVar): outp <- getChanContents io if and (zipWith (==) inp outp) then putStrLn "OK" else error $ "Smoke test failed" {- -- WORKS: forM_ inp $ \xIn-> do xOut <- readChan io unless (xIn == xOut) $ error $ "Smoke test failed" -} }}} I first noticed the behavior in a Chan-like library I wrote, whose internals are completely different from Chan, but where the getChanContents is a copy-paste from Chan. So I assume it has something to do with `unsafeInterleaveIO`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9965 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9965: getChanContents BlockedIndefinitelyOnMVar on 7.10 RC1 -------------------------------------+------------------------------------- Reporter: jberryman | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by jberryman): Adding another `unsafeInterleaveIO` seems to solve this, but I don't really understand why: {{{#!haskell getChanContents :: Chan a -> IO [a] getChanContents ch = unsafeInterleaveIO (do x <- unsafeInterleaveIO $ readChan ch -- <------ unsafeInterleaveIO xs <- getChanContents ch return (x:xs) ) }}} I'll attach the output of `ghc --make -O2 -fforce-recomp -ddump-to-file -ddump-simpl -dsuppress-module-prefixes -dsuppress-uniques Main.hs` for both 7.8 and 7.10, using both the old version of `getChanContents` and the new version above. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9965#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9965: getChanContents BlockedIndefinitelyOnMVar on 7.10 RC1 -------------------------------------+------------------------------------- Reporter: jberryman | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: libraries/base | Version: 7.10.1-rc1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by rwbarton): * status: new => closed * resolution: => fixed Comment: Works for me with 7.10 RC 2 and 7.10.1, highly likely to have been a result of #9949. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9965#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC