[GHC] #9130: Segmentation fault in ThreadPaused.c:223 when compiled with -O
#9130: Segmentation fault in ThreadPaused.c:223 when compiled with -O ----------------------------------+---------------------------------- Reporter: twi | Owner: simonmar Type: bug | Status: new Priority: high | Milestone: Component: Runtime System | Version: 7.8.2 Keywords: | Operating System: Linux Architecture: x86_64 (amd64) | Type of failure: Runtime crash Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ----------------------------------+---------------------------------- Compiling the following program with {{{ghc --make -fforce-recomp -O Tests}}} gives me a segmentation fault when running the resulting executable whereas without {{{-O}}} it runs to completion. {{{ module Main where import Control.Concurrent.Async main :: IO () main = test 100 test :: Int -> IO () test s = do mapM_ wait =<< mapM b [0 .. s] where b _ = async $ return () }}} valgrind and gdb indicate that an invalid read in threadPaused is causing this: {{{ $ valgrind ./Tests ==17550== Memcheck, a memory error detector ==17550== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==17550== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info ==17550== Command: ./Tests ==17550== ==17550== Invalid read of size 4 ==17550== at 0x46C2BE: threadPaused (ThreadPaused.c:223) ==17550== by 0x48FC72: stg_returnToSched (in /tmp/xxx/Tests) ==17550== Address 0x1f is not stack'd, malloc'd or (recently) free'd ==17550== ==17550== ==17550== Process terminating with default action of signal 11 (SIGSEGV) ==17550== Access not within mapped region at address 0x1F ==17550== at 0x46C2BE: threadPaused (ThreadPaused.c:223) ==17550== by 0x48FC72: stg_returnToSched (in /tmp/xxx/Tests) ==17550== If you believe this happened as a result of a stack ==17550== overflow in your program's main thread (unlikely but ==17550== possible), you can try to increase the size of the ==17550== main thread stack using the --main-stacksize= flag. ==17550== The main thread stack size used in this run was 8388608. ==17550== ==17550== HEAP SUMMARY: ==17550== in use at exit: 76,884 bytes in 34 blocks ==17550== total heap usage: 53 allocs, 19 frees, 81,122 bytes allocated ==17550== ==17550== LEAK SUMMARY: ==17550== definitely lost: 0 bytes in 0 blocks ==17550== indirectly lost: 0 bytes in 0 blocks ==17550== possibly lost: 0 bytes in 0 blocks ==17550== still reachable: 76,884 bytes in 34 blocks ==17550== suppressed: 0 bytes in 0 blocks ==17550== Rerun with --leak-check=full to see details of leaked memory ==17550== ==17550== For counts of detected and suppressed errors, rerun with: -v ==17550== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 3) Segmentation fault (core dumped) }}} {{{ (gdb) run Starting program: /tmp/xxx/Tests warning: Could not load shared library symbols for linux-vdso.so.1. Do you need "set solib-search-path" or "set sysroot"? [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. 0x000000000046c2be in threadPaused (cap=0x6f5dc0 <MainCapability>, tso=0x7ffff6b05390) at rts/ThreadPaused.c:223 223 switch (info->i.type) { (gdb) info locals frame = 0x7ffff6b050f0 info = 0xf bh_info = 0x4779fe <appendToRunQueue+155> bh = 0x7ffff6b10790 stack_end = 0x7ffff6b05390 words_to_squeeze = 0 weight = 0 weight_pending = 9 prev_was_update_frame = rtsFalse }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9130> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9130: Segmentation fault in ThreadPaused.c:223 when compiled with -O -----------------------------------+---------------------------------- Reporter: twi | Owner: simonmar Type: bug | Status: new Priority: high | Milestone: Component: Runtime System | Version: 7.8.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+---------------------------------- Comment (by ezyang): I cannot reproduce on HEAD (7d958ce323e3433c9e996e1a240a5741bfcfc341). {{{ [ezyang@hs01 ghc-validate]$ cabal install --with-ghc=/home/hs01/ezyang /ghc-validate/inplace/bin/ghc-stage2 async Resolving dependencies... Configuring stm-2.4.3... Building stm-2.4.3... Preprocessing library stm-2.4.3... [ 1 of 10] Compiling Control.Sequential.STM ( Control/Sequential/STM.hs, dist/build/Control/Sequential/STM.o ) [ 2 of 10] Compiling Control.Concurrent.STM.TBQueue ( Control/Concurrent/STM/TBQueue.hs, dist/build/Control/Concurrent/STM/TBQueue.o ) [ 3 of 10] Compiling Control.Concurrent.STM.TQueue ( Control/Concurrent/STM/TQueue.hs, dist/build/Control/Concurrent/STM/TQueue.o ) [ 4 of 10] Compiling Control.Concurrent.STM.TChan ( Control/Concurrent/STM/TChan.hs, dist/build/Control/Concurrent/STM/TChan.o ) [ 5 of 10] Compiling Control.Concurrent.STM.TMVar ( Control/Concurrent/STM/TMVar.hs, dist/build/Control/Concurrent/STM/TMVar.o ) [ 6 of 10] Compiling Control.Concurrent.STM.TVar ( Control/Concurrent/STM/TVar.hs, dist/build/Control/Concurrent/STM/TVar.o ) [ 7 of 10] Compiling Control.Concurrent.STM.TArray ( Control/Concurrent/STM/TArray.hs, dist/build/Control/Concurrent/STM/TArray.o ) [ 8 of 10] Compiling Control.Monad.STM ( Control/Monad/STM.hs, dist/build/Control/Monad/STM.o ) [ 9 of 10] Compiling Control.Concurrent.STM ( Control/Concurrent/STM.hs, dist/build/Control/Concurrent/STM.o ) [10 of 10] Compiling Control.Concurrent.STM.TSem ( Control/Concurrent/STM/TSem.hs, dist/build/Control/Concurrent/STM/TSem.o ) In-place registering stm-2.4.3... Installing library in /home/u1/ezyang/.cabal/lib/x86_64-linux-ghc-7.9.20140520/stm-2.4.3 Registering stm-2.4.3... Installed stm-2.4.3 Configuring async-2.0.1.5... Building async-2.0.1.5... Preprocessing library async-2.0.1.5... [1 of 1] Compiling Control.Concurrent.Async ( Control/Concurrent/Async.hs, dist/build/Control/Concurrent/Async.o ) In-place registering async-2.0.1.5... Installing library in /home/u1/ezyang/.cabal/lib/x86_64-linux-ghc-7.9.20140520/async-2.0.1.5 Registering async-2.0.1.5... Installed async-2.0.1.5 [ezyang@hs01 ghc-validate]$ vim Tests.hs ld/Control/Concurrent/STM/TArray.o ) [ 8 of 10] Compiling Control.Monad.STM ( Control/Monad/STM.hs, dist/build/Control/Monad/STM.o ) [ 9 of 10] Compiling Control.Concurrent.STM ( Control/Concurrent/STM.hs, dist/build/Control/Concurrent/STM.o ) [10 of 10] Compiling Control.Concurrent.STM.TSem ( Control/Concurrent/STM/TSem.hs, dist/build/Control/Concurrent/STM/TSem.o ) In-place registering stm-2.4.3... Installing library in /home/u1/ezyang/.cabal/lib/x86_64-linux-ghc-7.9.20140520/stm-2.4.3 Registering stm-2.4.3... Installed stm-2.4.3 Configuring async-2.0.1.5... Building async-2.0.1.5... Preprocessing library async-2.0.1.5... [1 of 1] Compiling Control.Concurrent.Async ( Control/Concurrent/Async.hs, dist/build/Control/Concurrent/Async.o ) In-place registering async-2.0.1.5... Installing library in /home/u1/ezyang/.cabal/lib/x86_64-linux-ghc-7.9.20140520/async-2.0.1.5 Registering async-2.0.1.5... Installed async-2.0.1.5 [ezyang@hs01 ghc-validate]$ vim Tests.hs [ezyang@hs01 ghc-validate]$ inplace/bin/ghc-stage2 --make -fforce-recomp -O Tests [1 of 1] Compiling Main ( Tests.hs, Tests.o ) Linking Tests ... [ezyang@hs01 ghc-validate]$ ./Tests [ezyang@hs01 ghc-validate]$ valgrind ./Tests ==24993== Memcheck, a memory error detector ==24993== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==24993== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info ==24993== Command: ./Tests ==24993== ==24993== ==24993== HEAP SUMMARY: ==24993== in use at exit: 4,108 bytes in 2 blocks ==24993== total heap usage: 51 allocs, 49 frees, 64,682 bytes allocated ==24993== ==24993== LEAK SUMMARY: ==24993== definitely lost: 0 bytes in 0 blocks ==24993== indirectly lost: 0 bytes in 0 blocks ==24993== possibly lost: 0 bytes in 0 blocks ==24993== still reachable: 4,108 bytes in 2 blocks ==24993== suppressed: 0 bytes in 0 blocks ==24993== Rerun with --leak-check=full to see details of leaked memory ==24993== ==24993== For counts of detected and suppressed errors, rerun with: -v ==24993== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 1 from 1) }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9130#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9130: Segmentation fault in ThreadPaused.c:223 when compiled with -O -----------------------------------+---------------------------------- Reporter: twi | Owner: simonmar Type: bug | Status: closed Priority: high | Milestone: Component: Runtime System | Version: 7.8.2 Resolution: duplicate | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+---------------------------------- Changes (by simonmar): * status: new => closed * resolution: => duplicate Comment: Fails in 7.8.2 but not in HEAD; I suspect this is #9045. Please test with the 7.8.3 RC when it comes out and re-open if it still fails. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9130#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC