SIGSEGV in yieldCapability () when using Control.Parallel
When running with -N12 and using parMap from Control.Parallel my code gives random segfaults. The function being mapped in parallel is pure but uses hmatrix which makes FFI calls to liblapack.
Using gdb on my code compiled with -debug, and using +RTS -N12 I get:
Main: internal error: ASSERTION FAILED: file rts/Capability.c, line 637
(GHC version 7.0.4 for x86_64_unknown_linux)
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Program received signal SIGABRT, Aborted.
0x00007ffff560f405 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) where
#0 0x00007ffff560f405 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff5612680 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x0000000000c1c322 in rtsFatalInternalErrorFn ()
#3 0x0000000000c1bf4b in barf ()
#4 0x0000000000c1bfae in _assertFail ()
#5 0x0000000000c18f18 in yieldCapability ()
#6 0x0000000000c1e516 in scheduleYield ()
#7 0x0000000000c1dbf7 in schedule ()
#8 0x0000000000c1ff95 in scheduleWaitThread ()
#9 0x0000000000c5f3c0 in rts_evalLazyIO ()
#10 0x0000000000c1bdaf in real_main ()
#11 0x0000000000c1be9e in hs_main ()
#12 0x00007ffff55fbead in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#13 0x00000000004097ed in _start ()
(gdb)
I also get the same thing even if using only -N2.
The end of the output from -Ds looks like:
7f9e73393700: returning; I want capability 3
7f9e73393700: resuming capability 3
7f9e73393700: cap 3: running thread 20547 (ThreadRunGHC)
7f9e73393700: cap 3: thread 20547 stopped (suspended while making a foreign call)
7f9e73393700: freeing capability 3
7f9e73393700: returning; I want capability 3
7f9e73393700: resuming capability 3
7f9e73393700: cap 3: running thread 20547 (ThreadRunGHC)
7f9e73393700: cap 3: thread 20547 stopped (suspended while making a foreign call)
7f9e73393700: freeing capability 3
7f9e73393700: returning; I want capability 3
7f9e73393700: resuming capability 3
7f9e73393700: cap 3: running thread 20547 (ThreadRunGHC)
7f9e73393700: cap 3: thread 20547 stopped (suspended while making a foreign call)
7f9e73393700: freeing capability 3
7f9e73393700: returning; I want capability 3
7f9e73393700: resuming capability 3
7f9e73393700: cap 3: running thread 20547 (ThreadRunGHC)
7f9e73393700: cap 3: thread 20547 stopped (suspended while making a foreign call)
7f9e73393700: freeing capability 3
7f9e73393700: returning; I want capability 3
7f9e73393700: resuming capability 3
7f9e73393700: cap 3: running thread 20547 (ThreadRunGHC)
7f9e73393700: cap 3: thread 20547 stopped (suspended while making a foreign call)
7f9e73393700: freeing capability 3
7f9e73393700: returning; I want capability 3
7f9e73393700: resuming capability 3
7f9e73393700: cap 3: running thread 20547 (ThreadRunGHC)
7f9e73393700: cap 3: thread 20547 stopped (suspended while making a foreign call)
7f9e73393700: freeing capability 3
7f9e73393700: returning; I want capability 3
7f9e73393700: resuming capability 3
7f9e73393700: cap 3: running thread 20547 (ThreadRunGHC)
7f9e73393700: cap 3: Trying to steal work from other capabilities
7f9e73393700: No sparks stolen
7f9e73393700: cap 3: thread 20547 stopped (finished)
7f9e73393700: giving up capability 3
7f9e73393700: freeing capability 3
7f9e77502700: woken up on capability 3
7f9e77502700: resuming capability 3
7f9e71b90700: woken up on capability 6
Main: internal error: ASSERTION FAILED: file rts/Capability.c, line 637
7f9e71b90700: resuming capability 6
7f9e71b90700: giving up capability 6
(GHC version 7.0.4 for x86_64_unknown_linux)
7f9e71b90700: freeing capability 6
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
7f9e73b94700: cap 2: thread 20546 stopped (suspended while making a foreign call)
7f9e73b94700: %
I wasn't sure whether or not to report this until I investigated further and found what appears to be the same bug reported previously: http://hackage.haskell.org/trac/ghc/ticket/5214
I tried to create a test case but it doesn't cause segfaults. I can't share the program publicly but would be happy to send it to someone privately if that would help.