[GHC] #9965: getChanContents BlockedIndefinitelyOnMVar on 7.10 RC1

GHC ghc-devs at haskell.org
Mon Jan 19 18:47:25 UTC 2015


#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


More information about the ghc-tickets mailing list