[GHC] #14356: "Main: thread blocked indefinitely in an MVar operation" in fixIO
GHC
ghc-devs at haskell.org
Thu Oct 19 16:57:46 UTC 2017
#14356: "Main: thread blocked indefinitely in an MVar operation" in fixIO
-------------------------------------+-------------------------------------
Reporter: nickkuk | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Runtime System | Version: 8.2.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by alexbiehl):
By using a lazy pattern match it is working again:
{{{
main = fixIO (\ ~(x, _) -> return (1, print x)) >>= print . fst
}}}
Looking at the core for the reported version we find: (compiled with -O2
to better understand the flow)
{{{#!haskell
main1
= \ s_a1AP ->
case newMVar# s_a1AP of { (# ipv_a1AZ, ipv1_a1B0 #) ->
case ((unsafeDupableInterleaveIO
((\ eta_a1B8 -> readMVar# ipv1_a1B0 eta_a1B8) `cast`
<Co:6>))
`cast` <Co:5>)
ipv_a1AZ
of
{ (# ipv2_X1B5, ipv3_X1B7 #) ->
-- ipv3_X1B7 is our chunk which delays the readMVar#
-- entering ipv3_X1B7 causes a deadlock!
case ipv3_X1B7 of { (x_aV8, ds2_d1zX) ->
case putMVar#
ipv1_a1B0
(main3,
(hPutStr2 stdout ($fShowInteger_$cshow x_aV8) True) `cast`
<Co:3>)
ipv2_X1B5
of s2#_a25J
{ __DEFAULT ->
hPutStr2 stdout main2 True s2#_a25J
}
}
}
}
}}}
By using a strict pattern match on the tuple we trigger the `readMVar#`
which blocks and deadlocks as we can't make further progress.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14356#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list