#1391: forkProcess() in Schedule.c with -threaded should initialize mutexes in
child process (POSIX)
-------------------------------+--------------------------------------------
Reporter: thorkilnaur | Owner:
Type: bug | Status: new
Priority: high | Milestone: 6.8 branch
Component: Runtime System | Version: 6.7
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Os: MacOS X | Testcase: forkprocess01(ghci)
Architecture: powerpc |
-------------------------------+--------------------------------------------
Comment (by guest):
With your patch
{{{
Fri Sep 14 16:55:19 CEST 2007 Simon Marlow <[EMAIL PROTECTED]>
* attempt to fix #1391, hold locks across fork() and initialize them in
the child
}}}
the forkprocess01 test still fails:
{{{
$ make TEST=forkprocess01 stage=2 WAY=ghci
...
=====> forkprocess01(ghci)
cd . && '/Users/thorkilnaur/tn/GHCDarcsRepository/ghc-HEAD-complete-for-
pulling-and-copying-20070713_1212/ghc/compiler/stage2/ghc-inplace' -no-
recomp -dcore-lint -dcmm-lint -Dpowerpc_apple_darwin forkprocess01.hs
--interactive -v0 -package unix <forkprocess01.genscript
1>forkprocess01.interp.stdout 2>forkprocess01.interp.stderr
Actual stdout output differs from expected:
--- ./forkprocess01.stdout.normalised 2007-09-26 20:34:18.000000000
+0200
+++ ./forkprocess01.run.stdout.normalised 2007-09-26
20:34:18.000000000 +0200
@@ -1 +1 @@
-Just (Exited (ExitFailure 72))
+Just (Terminated 11)
*** unexpected failure for forkprocess01(ghci)
OVERALL SUMMARY for test run started at Wed Sep 26 20:34:14 CEST 2007
7 total tests, which gave rise to
49 test cases, of which
0 caused framework failures
48 were skipped
0 expected passes
0 expected failures
0 unexpected passes
1 unexpected failures
Unexpected failures:
forkprocess01(ghci)
$
}}}
The crash report indicates a problem related to the locks:
{{{
**********
Host Name: Thorkil-Naurs-Computer
Date/Time: 2007-09-26 21:03:17.246 +0200
OS Version: 10.4.10 (Build 8R218)
Report Version: 4
Command: ghc-6.9.20070925
Path: /Users/thorkilnaur/tn/GHCDarcsRepository/ghc-HEAD-complete-for-
pulling-and-copying-20070713_1212/ghc/compiler/stage2/ghc-6.9.20070925
Parent: ghc-6.9.20070925 [13662]
Version: ??? (???)
PID: 13665
Thread: 0
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0xfffffffc
Thread 0 Crashed:
0 libSystem.B.dylib 0x9002c514 restore_sem_to_pool + 84
1 libSystem.B.dylib 0x90001c94 pthread_mutex_lock + 604
2 ghc-6.9.20070925 0x012af064 waitForReturnCapability + 224
(crt.c:355)
3 ghc-6.9.20070925 0x0117e780 scheduleDoGC + 180 (crt.c:355)
4 ghc-6.9.20070925 0x0117ea88 exitScheduler + 96 (crt.c:355)
5 ghc-6.9.20070925 0x012a52fc hs_exit_ + 112 (crt.c:355)
6 ghc-6.9.20070925 0x012a5428 shutdownHaskellAndExit + 48 (crt.c:355)
7 <<00000000>> 0x041425c4 0 + 68429252
8 ghc-6.9.20070925 0x0117fa30 schedule + 820 (crt.c:355)
9 ghc-6.9.20070925 0x012a37e4 rts_evalStableIO + 72 (crt.c:355)
10 ghc-6.9.20070925 0x0117ec6c forkProcess + 368 (crt.c:355)
11 <<00000000>> 0x0321c580 0 + 52544896
12 ghc-6.9.20070925 0x0117fa30 schedule + 820 (crt.c:355)
13 ghc-6.9.20070925 0x0117ff1c workerStart + 88 (crt.c:355)
14 libSystem.B.dylib 0x9002bd08 _pthread_body + 96
Thread 1:
0 <<00000000>> 0xffff85d8 __spin_lock_relinquish + 24
(cpu_capabilities.h:186)
1 libSystem.B.dylib 0x90001a94 pthread_mutex_lock + 92
2 ghc-6.9.20070925 0x012aec68 releaseCapability_ + 296 (crt.c:355)
3 ghc-6.9.20070925 0x012af224 yieldCapability + 156 (crt.c:355)
4 ghc-6.9.20070925 0x0117e734 scheduleDoGC + 104 (crt.c:355)
5 ghc-6.9.20070925 0x0117f7a0 schedule + 164 (crt.c:355)
6 ghc-6.9.20070925 0x0117ff1c workerStart + 88 (crt.c:355)
7 libSystem.B.dylib 0x9002bd08 _pthread_body + 96
Thread 0 crashed with PPC Thread State 64:
srr0: 0x000000009002c514 srr1: 0x000000000200f030
vrsave: 0x0000000000000000
cr: 0x22000224 xer: 0x0000000020000000 lr:
0x000000009002c4f8 ctr: 0x000000009002c4c0
r0: 0x0000000000000001 r1: 0x00000000f00fd7d0 r2:
0x00000000ffffffff r3: 0x00000000a000f014
r4: 0x0000000000000000 r5: 0x0000000000000000 r6:
0x00000000ffffffff r7: 0x0000000000000000
r8: 0x0000000000000000 r9: 0x0000000000000000 r10:
0x00000000a000c4c8 r11: 0x00000000fffffffc
r12: 0x000000009002c4c0 r13: 0x0000000000000000 r14:
0x0000000003414079 r15: 0x0000000000000048
r16: 0x00000000035ebf61 r17: 0x00000000035eb6dd r18:
0x00000000042abb2d r19: 0x0000000000000000
r20: 0x0000000000000000 r21: 0x0000000000000000 r22:
0x0000000000000000 r23: 0x00000000035ebf61
r24: 0x00000000014e0000 r25: 0x0000000012141968 r26:
0x00000000a0001a48 r27: 0x0000000003100510
r28: 0x00000000a0001fac r29: 0x000000009fffc4c8 r30:
0x0000000000001003 r31: 0x000000009002c4c8
Binary Images Description:
0x1000 - 0x142ffff ghc-6.9.20070925
/Users/thorkilnaur/tn/GHCDarcsRepository/ghc-HEAD-complete-for-pulling-
and-copying-20070713_1212/ghc/compiler/stage2/ghc-6.9.20070925
0x2705000 - 0x2730fff GMP
/Library/Frameworks/GMP.framework/Versions/A/GMP
0x8fe00000 - 0x8fe52fff dyld 46.12 /usr/lib/dyld
0x90000000 - 0x901bcfff libSystem.B.dylib /usr/lib/libSystem.B.dylib
0x90214000 - 0x90219fff libmathCommon.A.dylib
/usr/lib/system/libmathCommon.A.dylib
}}}
Inspired by some experiments I made when investigating this some time ago,
I introduced initialization of additional locks, as sketched in the
attached patch. With that change, the segmentation fault disappears and
forkprocess01(ghci) succeeds. I should stress that I don't consider this
patch in any way the solution to the problem, something additional or
different will surely be needed. But I need to leave the matter in this,
somewhat unresolved state for now.
Best regards Thorkil
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1391#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs