[GHC] #13330: forkIO has inconsistent behavior under optimization
GHC
ghc-devs at haskell.org
Fri Feb 24 03:26:28 UTC 2017
#13330: forkIO has inconsistent behavior under optimization
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.2.1
Component: Core | Version: 8.1
Libraries |
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: Other
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Troubleshooting the T4030 failure in SimonPJ's early-inline branch, Reid
and I discovered that the problem showed up when the argument to `forkIO`
was obviously bottom. He came up with a tiny test case that fails without
Simon's changes:
{{{#!hs
main = forkIO undefined >> threadDelay 1000000
}}}
It looks like the trouble is in the definition of `forkIO`:
{{{#!hs
forkIO :: IO () -> IO ThreadId
forkIO action = IO $ \ s ->
case (fork# action_plus s) of (# s1, tid #) -> (# s1, ThreadId tid #)
where
action_plus = catchException action childHandler
}}}
This seems to run into the trouble with `catchException` and strictness
explained in `GHC.IO`. It would appear that the conservative fix would be
to replace `catchException` with `catch`. Personally, I find it a bit
surprising that `forkIO` doesn't force its `IO` argument before forking,
but changing that behavior could break working code.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13330>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list