Opened 5 years ago

Last modified 5 years ago

#9470 new bug

forkProcess breaks in multiple ways with GHC 7.6

Reported by: nh2 Owned by: simonmar
Priority: normal Milestone:
Component: Runtime System Version: 7.8.3
Keywords: Cc: edsko, simonmar, mail@…, snoyberg, ppud
Operating System: Linux Architecture: Unknown/Multiple
Type of failure: Runtime crash Test Case:
Blocked By: Blocking:
Related Tickets: #9468 Differential Rev(s):
Wiki Page:

Description (last modified by nh2)

When I run this program using forkProcess

in GHC 7.6.3 on Ubuntu 12.04 and 14.04 I get at 4 different issues. Three of them (1-3) crash the program, and happen only on some startups, the fourth one is the part for which I originally wrote this test case.

  1. A segfault shortly after startup (probably in the GC)
  2. internal error: resurrectThreads: thread blocked in a strange way: 10 at startup
  3. A glibc corrupted double-linked list shortly after startup
  4. The running, killing by SIGTERM case inside my program

Now come the details for each of them:

  1. I managed to get a gdb trace of it ( and also a trace with the -debug runtime ( They suggest that the segfault is in evacuate(), and the -debug one says it's in the LOOKS_LIKE_CLOSURE_PTR part.
  2. This is the same as my newly reported #9468 and I have no clue what that's about. Output:
  3. This one happens very rarely; might be related to 1? Output:
  4. The problem here is the Nothing case: The child process didn't answer from the pipe, and that although it is still running, so it really should have answered. It seems that for every 20th fork or so, the child process just hangs.

All files, error outputs and IRC logs are also collected in this gist:

For getting issues (1-3), you have to run them multiple times in order to reproduce; if they appear, they will appear within the first second after startup. Which of the issue appears is dependent on how many _FORKS you set (with a high number like the default 80, you mostly get issue 2; set down to 8 to make the other ones more probably) and with how many +RTS -N threads you run.

2 and 4 are definitely present in 7.8.3 as well.

For 1 and 3, it would be great if you could tell me whether these are known issues and are known to be fixed in 7.8.

Change History (6)

comment:1 Changed 5 years ago by nh2

Description: modified (diff)

comment:2 Changed 5 years ago by snoyberg

Cc: snoyberg added

comment:3 Changed 5 years ago by ppud

Cc: ppud added

comment:4 Changed 5 years ago by hvr

comment:5 Changed 5 years ago by nh2

As a side note: In unix- (GHC 7.2), the haddocks of forkProcess say

"GHC note: forkProcess is not currently supported when using multiple processors (+RTS -N), although it is supported with -threaded as long as only one processor is being used."

but as of unix- (GHC 7.4) that note is gone.

comment:6 Changed 5 years ago by nh2

It seems that issue 4 can be worked around by restricting to 1 fork at a time (suggesed by carter):

main :: IO ()
main = do

  let _FORKS = 8

  withLock <- do
    m <- newMVar ()
    return $ \f -> withMVar m (\() -> f)

  forM_ [1.._FORKS :: Int] $ \i -> forkIO $
    forever $ withLock $ forkJobProcess ("Job" ++ show i)

  _ <- getLine
  return ()
Note: See TracTickets for help on using tickets.