
#14271: ghci hangs with -fexternal-interpreter -prof -------------------------------------+------------------------------------- Reporter: AndreasK | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.2.1 Resolution: duplicate | Keywords: RemoteGHCi Operating System: Windows | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #16162 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): For the record, I have reported a number of external-interpreter-related testsuite failures on Windows in #16156. The most common failure mode is the test timing-out, which I suspect is due to this hang reported in this ticket. My suspicion is that GHC's logic to detect the death of its `iserv` process is broken on Windows. I did the following to test this: 1. start `ghci -fexternal-interpreter` 2. issue a kill request against its associated interpreter process (using the "kill" command in Process Explorer) 3. try evaluating `print "hello"` 4. observe that `ghci` indeed hangs However, I should note that in this experiment the kill request against the interpreter doesn't actually kill the interpreter process. Rather it seems to merely hang. Issuing a *second* kill command indeed kills it, at which point `ghci` realizes the interpreter is dead and terminates. The backtrace of the interpreter process in its hung state looks like the following: {{{ (gdb) thread apply all bt Thread 6 (Thread 9232.0x19ac): #0 0x00007ffa06549351 in ntdll!DbgBreakPoint () from /c/Windows/SYSTEM32/ntdll.dll #1 0x00007ffa065710ba in ntdll!DbgUiRemoteBreakin () from /c/Windows/SYSTEM32/ntdll.dll #2 0x00007ffa061c8364 in KERNEL32!BaseThreadInitThunk () from /c/Windows/System32/KERNEL32.DLL #3 0x00007ffa0650e851 in ntdll!RtlUserThreadStart () from /c/Windows/SYSTEM32/ntdll.dll #4 0x0000000000000000 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?) Thread 5 (Thread 9232.0x1c5c): #0 0x00007ffa06545b84 in ntdll!ZwWaitForSingleObject () from /c/Windows/SYSTEM32/ntdll.dll #1 0x00007ffa03413ebf in WaitForSingleObjectEx () from /c/Windows/System32/KERNELBASE.dll #2 0x0000000003d70543 in waitCondition (pCond=pCond@entry=0x6c2c768, pMut=pMut@entry=0x6c2c770) at rts\win32\OSThreads.c:87 #3 0x0000000003d54d60 in waitForWorkerCapability (task=0x6c2c760) at rts\Capability.c:651 #4 yieldCapability (pCap=pCap@entry=0x857fe88, task=task@entry=0x6c2c760, gcAllowed=gcAllowed@entry=true) at rts\Capability.c:888 #5 0x0000000003d57191 in scheduleYield (task=0x6c2c760, pcap=0x857fea0) at rts\Schedule.c:672 #6 schedule (initialCapability=<optimized out>, task=<optimized out>, task@entry=0x6c2c760) at rts\Schedule.c:292 #7 0x0000000003d5826f in scheduleWorker (cap=<optimized out>, task=0x6c2c760) at rts\Schedule.c:2550 #8 0x0000000003d7e4f8 in workerStart (task=0x6c2c760) at rts\Task.c:444 #9 0x00007ffa061c8364 in KERNEL32!BaseThreadInitThunk () from /c/Windows/System32/KERNEL32.DLL #10 0x00007ffa0650e851 in ntdll!RtlUserThreadStart () from /c/Windows/SYSTEM32/ntdll.dll #11 0x0000000000000000 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?) Thread 4 (Thread 9232.0x20b8): #0 0x00007ffa06545b84 in ntdll!ZwWaitForSingleObject () from /c/Windows/SYSTEM32/ntdll.dll #1 0x00007ffa03413ebf in WaitForSingleObjectEx () from /c/Windows/System32/KERNELBASE.dll #2 0x0000000003d70543 in waitCondition (pCond=pCond@entry=0x4d8ee88, pMut=pMut@entry=0x4d8ee90) at rts\win32\OSThreads.c:87 #3 0x0000000003d54d60 in waitForWorkerCapability (task=0x4d8ee80) at rts\Capability.c:651 #4 yieldCapability (pCap=pCap@entry=0x770fe88, task=task@entry=0x4d8ee80, gcAllowed=gcAllowed@entry=true) at rts\Capability.c:888 #5 0x0000000003d57191 in scheduleYield (task=0x4d8ee80, pcap=0x770fea0) at rts\Schedule.c:672 #6 schedule (initialCapability=<optimized out>, task=<optimized out>, task@entry=0x4d8ee80) at rts\Schedule.c:292 #7 0x0000000003d5826f in scheduleWorker (cap=<optimized out>, task=0x4d8ee80) at rts\Schedule.c:2550 #8 0x0000000003d7e4f8 in workerStart (task=0x4d8ee80) at rts\Task.c:444 #9 0x00007ffa061c8364 in KERNEL32!BaseThreadInitThunk () from /c/Windows/System32/KERNEL32.DLL #10 0x00007ffa0650e851 in ntdll!RtlUserThreadStart () from /c/Windows/SYSTEM32/ntdll.dll #11 0x0000000000000000 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?) Thread 3 (Thread 9232.0x2098): #0 0x00007ffa06545b84 in ntdll!ZwWaitForSingleObject () from /c/Windows/SYSTEM32/ntdll.dll #1 0x00007ffa03413ebf in WaitForSingleObjectEx () from /c/Windows/System32/KERNELBASE.dll #2 0x0000000003c5745d in caqi_info () #3 0x0000000004d8e7e0 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?) Thread 2 (Thread 9232.0x7ac): #0 0x00007ffa065492d4 in ntdll!ZwWaitForWorkViaWorkerFactory () from /c/Windows/SYSTEM32/ntdll.dll #1 0x00007ffa064c9e4e in ntdll!RtlReleaseSRWLockExclusive () from /c/Windows/SYSTEM32/ntdll.dll #2 0x00007ffa061c8364 in KERNEL32!BaseThreadInitThunk () from /c/Windows/System32/KERNEL32.DLL #3 0x00007ffa0650e851 in ntdll!RtlUserThreadStart () from /c/Windows/SYSTEM32/ntdll.dll #4 0x0000000000000000 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?) Thread 1 (Thread 9232.0x18d4): #0 0x00007ffa06545c04 in ntdll!ZwWriteFile () from /c/Windows/SYSTEM32/ntdll.dll #1 0x00007ffa034140e6 in WriteFile () from /c/Windows/System32/KERNELBASE.dll #2 0x00007ffa052e03db in msvcrt!_write () from /c/Windows/System32/msvcrt.dll #3 0x00007ffa052dfcca in msvcrt!_write () from /c/Windows/System32/msvcrt.dll #4 0x0000000003b2cc20 in s9ja_info () #5 0x0000000000000006 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14271#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler