[GHC] #13970: Segmentation fault inside threadPaused
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime | Version: 8.2.1-rc3 System | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- A multithreaded program generated by latest release candidate occasionally segfaults inside the runtime system. It is always at the same instruction: {{{ (gdb) bt #0 0x00007f25ca77fde3 in threadPaused () from /nix/store/995xifyvjlbvd138r0gpq008nyxls6hr- ghc-8.2.0.20170704/lib/ghc-8.2.0.20170704/rts/libHSrts_thr- ghc8.2.0.20170704.so #1 0x00007f25ca795068 in stg_returnToSched () from /nix/store/995xifyvjlbvd138r0gpq008nyxls6hr- ghc-8.2.0.20170704/lib/ghc-8.2.0.20170704/rts/libHSrts_thr- ghc8.2.0.20170704.so #2 0x0000000000000000 in ?? () (gdb) disassemble Dump of assembler code for function threadPaused: 0x00007f25ca77fda0 <+0>: push %r15 0x00007f25ca77fda2 <+2>: push %r14 0x00007f25ca77fda4 <+4>: push %r13 0x00007f25ca77fda6 <+6>: push %r12 0x00007f25ca77fda8 <+8>: mov %rdi,%r12 0x00007f25ca77fdab <+11>: push %rbp 0x00007f25ca77fdac <+12>: push %rbx 0x00007f25ca77fdad <+13>: mov %rsi,%rbp 0x00007f25ca77fdb0 <+16>: sub $0x28,%rsp 0x00007f25ca77fdb4 <+20>: callq 0x7f25ca77a640 <maybePerformBlockedException> 0x00007f25ca77fdb9 <+25>: cmpw $0x3,0x20(%rbp) 0x00007f25ca77fdbe <+30>: je 0x7f25ca77fe1d <threadPaused+125> 0x00007f25ca77fdc0 <+32>: mov 0x18(%rbp),%rax 0x00007f25ca77fdc4 <+36>: mov 0x8(%rax),%edx 0x00007f25ca77fdc7 <+39>: mov 0x10(%rax),%rbx 0x00007f25ca77fdcb <+43>: lea 0x18(%rax,%rdx,8),%r13 0x00007f25ca77fdd0 <+48>: cmp %rbx,%r13 0x00007f25ca77fdd3 <+51>: jbe 0x7f25ca77fe16 <threadPaused+118> 0x00007f25ca77fdd5 <+53>: xor %r9d,%r9d 0x00007f25ca77fdd8 <+56>: xor %r14d,%r14d 0x00007f25ca77fddb <+59>: xor %r15d,%r15d 0x00007f25ca77fdde <+62>: xor %ecx,%ecx 0x00007f25ca77fde0 <+64>: mov (%rbx),%rdx => 0x00007f25ca77fde3 <+67>: mov -0x8(%rdx),%eax 0x00007f25ca77fde6 <+70>: cmp $0x21,%eax 0x00007f25ca77fde9 <+73>: je 0x7f25ca77ff10 <threadPaused+368> 0x00007f25ca77fdef <+79>: jb 0x7f25ca77fed0 <threadPaused+304> 0x00007f25ca77fdf5 <+85>: lea -0x23(%rax),%esi 0x00007f25ca77fdf8 <+88>: cmp $0x1,%esi 0x00007f25ca77fdfb <+91>: ja 0x7f25ca77fed0 <threadPaused+304> 0x00007f25ca77fe01 <+97>: cmp $0x8,%r15d 0x00007f25ca77fe05 <+101>: setbe %dl 0x00007f25ca77fe08 <+104>: test %ecx,%ecx 0x00007f25ca77fe0a <+106>: setne %al 0x00007f25ca77fe0d <+109>: test %al,%dl 0x00007f25ca77fe0f <+111>: jne 0x7f25ca77fe30 <threadPaused+144> 0x00007f25ca77fe11 <+113>: cmp %r15d,%ecx 0x00007f25ca77fe14 <+116>: ja 0x7f25ca77fe30 <threadPaused+144> 0x00007f25ca77fe16 <+118>: andl $0xffffff7f,0x24(%rbp) 0x00007f25ca77fe1d <+125>: add $0x28,%rsp 0x00007f25ca77fe21 <+129>: pop %rbx 0x00007f25ca77fe22 <+130>: pop %rbp 0x00007f25ca77fe23 <+131>: pop %r12 0x00007f25ca77fe25 <+133>: pop %r13 0x00007f25ca77fe27 <+135>: pop %r14 0x00007f25ca77fe29 <+137>: pop %r15 0x00007f25ca77fe2b <+139>: retq 0x00007f25ca77fe2c <+140>: nopl 0x0(%rax) 0x00007f25ca77fe30 <+144>: lea 0x3e2c9(%rip),%rax # 0x7f25ca7be100 <RtsFlags> 0x00007f25ca77fe37 <+151>: cmpb $0x0,0x4c(%rax) 0x00007f25ca77fe3b <+155>: je 0x7f25ca77fe16 <threadPaused+118> 0x00007f25ca77fe3d <+157>: mov 0x18(%rbp),%rax 0x00007f25ca77fe41 <+161>: mov 0x10(%rax),%r14 0x00007f25ca77fe45 <+165>: cmp %rbx,%r14 0x00007f25ca77fe48 <+168>: lea -0x10(%r14),%r13 0x00007f25ca77fe4c <+172>: ja 0x7f25ca780082 <threadPaused+738> 0x00007f25ca77fe52 <+178>: xor %ecx,%ecx 0x00007f25ca77fe54 <+180>: jmp 0x7f25ca77fe70 <threadPaused+208> 0x00007f25ca77fe56 <+182>: nopw %cs:0x0(%rax,%rax,1) 0x00007f25ca77fe60 <+192>: add $0x1,%ecx 0x00007f25ca77fe63 <+195>: add $0x10,%r14 0x00007f25ca77fe67 <+199>: cmp %rbx,%r14 0x00007f25ca77fe6a <+202>: ja 0x7f25ca780060 <threadPaused+704> 0x00007f25ca77fe70 <+208>: mov (%r14),%rdx 0x00007f25ca77fe73 <+211>: mov -0x8(%rdx),%eax 0x00007f25ca77fe76 <+214>: cmp $0x21,%eax 0x00007f25ca77fe79 <+217>: je 0x7f25ca77fe60 <threadPaused+192> 0x00007f25ca77fe7b <+219>: cmp $0x1,%ecx 0x00007f25ca77fe7e <+222>: jbe 0x7f25ca77fe9b <threadPaused+251> 0x00007f25ca77fe80 <+224>: lea -0x10(%r14),%rdx 0x00007f25ca77fe84 <+228>: mov %r13,%r8 0x00007f25ca77fe87 <+231>: mov %rbp,%rsi 0x00007f25ca77fe8a <+234>: mov %r12,%rdi 0x00007f25ca77fe8d <+237>: callq 0x7f25ca77fce0 <updateAdjacentFrames> 0x00007f25ca77fe92 <+242>: mov (%r14),%rdx 0x00007f25ca77fe95 <+245>: mov %rax,%r13 0x00007f25ca77fe98 <+248>: mov -0x8(%rdx),%eax 0x00007f25ca77fe9b <+251>: cmp $0x1f,%eax 0x00007f25ca77fe9e <+254>: je 0x7f25ca780048 <threadPaused+680> 0x00007f25ca77fea4 <+260>: cmp $0x20,%eax 0x00007f25ca77fea7 <+263>: je 0x7f25ca780038 <threadPaused+664> 0x00007f25ca77fead <+269>: cmp $0x1d,%eax 0x00007f25ca77feb0 <+272>: je 0x7f25ca780020 <threadPaused+640> ... }}} Which I believe is the same place as reported in #9130. Apart from this error, the program also crashes, occasionally, with: {{{ sigym4-propag: internal error: scavenge_stack: weird activation record found on stack: -1717986919 (GHC version 8.2.0.20170704 for x86_64_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} (The activation record number changes between runs). I believe these to be related since I've found (after a long git-bisect session) that they both began manifesting themselves after the same GHC commit: c1c0985416a6f9766c03d361449f556905bf8e1d -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): I don't suppose you could provide a reproducer for this? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): What might also help is if you could compile your program with `-debug` and paste the output of `x/64a tso->stackobj->sp` after the program crashes. It seems like we are getting confused walking the stack, so it would be interesting to know what the stack looks like. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): Replying to [comment:2 bgamari]:
What might also help is if you could compile your program with `-debug` and paste the output of `x/64a tso->stackobj->sp` after the program crashes. It seems like we are getting confused walking the stack, so it would be interesting to know what the stack looks like.
I did but I still had no symbols in gdb. I must be striping them somewhere in my build... I will take a look and report back. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): Replying to [comment:1 bgamari]:
I don't suppose you could provide a reproducer for this?
It's hard for me to provide a reproducible example since it is in a complex proprietary program and I have of what could be causing this besides that increasing the number of capabilities with -N tends to increase the frequency of the crashes. I might be able to convince my employer to opensource the "engine" (a 2D spread simulation, which we use to simulate wildfires). I will certainly try to use this ticket as an argument in favor of doing that. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Note that I believe `Cabal` strips by default`.
It's hard for me to provide a reproducible example since it is in a complex proprietary program and I have of what could be causing this besides that increasing the number of capabilities with -N tends to increase the frequency of the crashes.
Quite understandable. Anything you can offer would be very much appreciated. I tested this patch with the testcase from #13615 with over a day of runtime without seeing this crash, so it seems that you are tickling something odd. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): If you aren't able to get debug symbols, I believe that the `StgTSO*` argument can be found at `*$rbp`. Consequently, `x/64a ((uint64_t*) $rbp)[0] + 0x10` will likely do the trick. For my future reference: `$rbx` contains `frame`, `$r13` contains `stack_end` -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): Replying to [comment:2 bgamari]:
What might also help is if you could compile your program with `-debug` and paste the output of `x/64a tso->stackobj->sp` after the program crashes. It seems like we are getting confused walking the stack, so it would be interesting to know what the stack looks like.
I finally managed to get debugging symbols. I had to pass {{{dontStrip = true}}} to the Nix derivation that builds ghc from git. Anyway, it crashed again at the same point and here's what gdb says: {{{ (gdb) x/64a tso->stackobj->sp 0x421cdbfea8: 0x7f9b3d2cc5c8 <stg_enter_info> 0x420c746c00 0x421cdbfeb8: 0x100 0x4204442df9 0x421cdbfec8: 0xf4 0xfffffffffffffff4 0x421cdbfed8: 0x7f9b3d2cce88 <stg_upd_frame_info> 0x420c746c00 0x421cdbfee8: 0x7f9b4367b308 <sigym4zmpropagzmenginezm0zi1zi0zi0zmFERo4wFJ8F465LTBnpBC6B_Sigym4ziPropagziEngine_zdwpolyzugo3_info+64> 0x6465c88fdad5932f 0x421cdbfef8: 0xffffffffffffffff 0x6 0x421cdbff08: 0x0 0x7f9b4367be08 0x421cdbff18: 0x42042655c8 0x42042655e0 0x421cdbff28: 0x4202361568 0x7f9b3d2cce88 <stg_upd_frame_info> 0x421cdbff38: 0x4204442dc8 0x7f9b436ac7b0 0x421cdbff48: 0x63b 0xffffffffffffffe4 0x421cdbff58: 0x420447bb61 0x7f9b441837a0 0x421cdbff68: 0x42187a9841 0x420447bb71 0x421cdbff78: 0xfffffffffffffff4 0x4204265518 0x421cdbff88: 0x42183d5c09 0x42183f1523 0x421cdbff98: 0x626 0x42187a0119 0x421cdbffa8: 0x7f9b3d2c8588 <stg_maskAsyncExceptionszh_ret_info> 0x7f9b3dbf2cc0 0x421cdbffb8: 0x7f9b3d2c8ae8 <stg_catch_frame_info> 0xc 0x421cdbffc8: 0x7f9b3e119592 0x7f9b3dbf2d80 0x421cdbffd8: 0x42183f155a 0x7f9b3d2c8ae8 <stg_catch_frame_info> 0x421cdbffe8: 0xc 0x7f9b3e14ee2a 0x421cdbfff8: 0x7f9b3d2c8088 <stg_stop_thread_info> 0x7f9b41aa3340 <linearzm1zi20zi6zm10zzIy9OH0MgIRAfBAdsUHU_LinearziV2_V2_con_info> 0x421cdc0008: 0x421cdc00d1 0x421cdc00c1 0x421cdc0018: 0x7f9b41aa3340 <linearzm1zi20zi6zm10zzIy9OH0MgIRAfBAdsUHU_LinearziV2_V2_con_info> 0x421cdc00f1 0x421cdc0028: 0x421cdc00e1 0x7f9b41aa3340 <linearzm1zi20zi6zm10zzIy9OH0MgIRAfBAdsUHU_LinearziV2_V2_con_info> 0x421cdc0038: 0x421cdc0111 0x421cdc0101 0x421cdc0048: 0x7f9b41aa3340 <linearzm1zi20zi6zm10zzIy9OH0MgIRAfBAdsUHU_LinearziV2_V2_con_info> 0x421cdc0131 0x421cdc0058: 0x421cdc0121 0x7f9b41aa3340 <linearzm1zi20zi6zm10zzIy9OH0MgIRAfBAdsUHU_LinearziV2_V2_con_info> 0x421cdc0068: 0x421cdc0151 0x421cdc0141 0x421cdc0078: 0x7f9b41aa3340 <linearzm1zi20zi6zm10zzIy9OH0MgIRAfBAdsUHU_LinearziV2_V2_con_info> 0x421cdc0171 0x421cdc0088: 0x421cdc0161 0x7f9b41aa3340 <linearzm1zi20zi6zm10zzIy9OH0MgIRAfBAdsUHU_LinearziV2_V2_con_info> 0x421cdc0098: 0x421cdc0191 0x421cdc0181 }}} BTW, I've got an approval to factor out the spread algorithm from our program as an opensource library so I'll begin working on that tomorrow. Hopefully the bug still manifests itself. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): Now that I have debugging symbols I can confirm that the segfault occurs in the {{{switch(info->i.type}}} line (224) reported in #9130 {{{ (gdb) bt #0 threadPaused (cap=0xc38ef0, tso=0x421dcc50f0) at rts/ThreadPaused.c:224 #1 0x00007f9b3d2c8275 in stg_returnToSched () from /nix/store/f46shfdh7qmagqw11w61g099jm544fd4-ghc-8.2.0.20170704/lib/ghc-8.2.0.20170704/rts /libHSrts_thr_debug-ghc8.2.0.20170704.so #2 0x0000000000000000 in ?? () }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): I've got a SEGFAULT in a new location which seems related to the same issue: {{{ Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00007f747043a32f in stg_BLACKHOLE_info () from /nix/store/ka5975xi1b7vcw98a1agqhb0y4gxcwbj- ghc-8.2.0.20170704/lib/ghc-8.2.0.20170704/rts/libHSrts_thr_debug- ghc8.2.0.20170704.so [Current thread is 1 (LWP 25315)] warning: File "/nix/store/xfrkm34sk0a13ha9bpki61l2k5g1v8dh- gcc-5.4.0-lib/lib/libstdc++.so.6.0.21-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto- load". (gdb) bt #0 0x00007f747043a32f in stg_BLACKHOLE_info () from /nix/store/ka5975xi1b7vcw98a1agqhb0y4gxcwbj- ghc-8.2.0.20170704/lib/ghc-8.2.0.20170704/rts/libHSrts_thr_debug- ghc8.2.0.20170704.so #1 0x0000000000000000 in ?? () (gdb) info locals No symbol table info available. (gdb) disassemble Dump of assembler code for function stg_BLACKHOLE_info: 0x00007f747043a240 <+0>: mov 0x8(%rbx),%rax 0x00007f747043a244 <+4>: test $0x7,%al 0x00007f747043a246 <+6>: jne 0x7f747043a32c <stg_BLACKHOLE_info+236> 0x00007f747043a24c <+12>: mov (%rax),%rcx 0x00007f747043a24f <+15>: cmp 0x2d7f2(%rip),%rcx # 0x7f7470467a48 0x00007f747043a256 <+22>: je 0x7f747043a240 <stg_BLACKHOLE_info> 0x00007f747043a258 <+24>: cmp 0x2d7e1(%rip),%rcx # 0x7f7470467a40 0x00007f747043a25f <+31>: je 0x7f747043a2a4 <stg_BLACKHOLE_info+100> 0x00007f747043a261 <+33>: cmp 0x2d7b0(%rip),%rcx # 0x7f7470467a18 0x00007f747043a268 <+40>: je 0x7f747043a2a4 <stg_BLACKHOLE_info+100> 0x00007f747043a26a <+42>: cmp 0x2d79f(%rip),%rcx # 0x7f7470467a10 0x00007f747043a271 <+49>: je 0x7f747043a2a4 <stg_BLACKHOLE_info+100> 0x00007f747043a273 <+51>: test $0x7,%al 0x00007f747043a275 <+53>: jne 0x7f747043a345 <stg_BLACKHOLE_info+261> 0x00007f747043a27b <+59>: mov (%rax),%rbx 0x00007f747043a27e <+62>: cmpl $0x1a,-0x8(%rbx) 0x00007f747043a282 <+66>: jb 0x7f747043a34b <stg_BLACKHOLE_info+267> 0x00007f747043a288 <+72>: cmpl $0x1c,-0x8(%rbx) 0x00007f747043a28c <+76>: jb 0x7f747043a332 <stg_BLACKHOLE_info+242> 0x00007f747043a292 <+82>: cmpl $0x1d,-0x8(%rbx) 0x00007f747043a296 <+86>: jb 0x7f747043a33c <stg_BLACKHOLE_info+252> 0x00007f747043a29c <+92>: mov %rbx,%rcx 0x00007f747043a29f <+95>: mov %rax,%rbx 0x00007f747043a2a2 <+98>: jmpq *%rcx 0x00007f747043a2a4 <+100>: lea -0xeebb(%rip),%rax # 0x7f747042b3f0 <allocate> 0x00007f747043a2ab <+107>: lea -0x18(%r13),%rcx 0x00007f747043a2af <+111>: mov $0x4,%edx 0x00007f747043a2b4 <+116>: sub $0x8,%rsp 0x00007f747043a2b8 <+120>: mov %rdx,%rsi 0x00007f747043a2bb <+123>: mov %rcx,%rdi 0x00007f747043a2be <+126>: mov %rax,%rcx 0x00007f747043a2c1 <+129>: xor %eax,%eax 0x00007f747043a2c3 <+131>: callq *%rcx 0x00007f747043a2c5 <+133>: add $0x8,%rsp 0x00007f747043a2c9 <+137>: lea 0x6e0(%rip),%rcx # 0x7f747043a9b0 <stg_MSG_BLACKHOLE_info> 0x00007f747043a2d0 <+144>: mov %rcx,(%rax) 0x00007f747043a2d3 <+147>: mov 0x368(%r13),%rcx 0x00007f747043a2da <+154>: mov %rcx,0x10(%rax) 0x00007f747043a2de <+158>: mov %rbx,0x18(%rax) 0x00007f747043a2e2 <+162>: lea -0x2e299(%rip),%rcx # 0x7f747040c050 <messageBlackHole> 0x00007f747043a2e9 <+169>: lea -0x18(%r13),%rdx 0x00007f747043a2ed <+173>: mov %rax,%rsi 0x00007f747043a2f0 <+176>: sub $0x8,%rsp 0x00007f747043a2f4 <+180>: mov %rdx,%rdi 0x00007f747043a2f7 <+183>: mov %rax,%rdx 0x00007f747043a2fa <+186>: xor %eax,%eax 0x00007f747043a2fc <+188>: mov %rdx,%r14 0x00007f747043a2ff <+191>: callq *%rcx 0x00007f747043a301 <+193>: add $0x8,%rsp 0x00007f747043a305 <+197>: test %rax,%rax 0x00007f747043a308 <+200>: je 0x7f747043a240 <stg_BLACKHOLE_info> 0x00007f747043a30e <+206>: mov 0x368(%r13),%rax 0x00007f747043a315 <+213>: movw $0x2,0x22(%rax) 0x00007f747043a31b <+219>: mov 0x368(%r13),%rax 0x00007f747043a322 <+226>: mov %r14,0x28(%rax) 0x00007f747043a326 <+230>: jmpq 0x7f7470438d58 <stg_block_blackhole> 0x00007f747043a32b <+235>: nop 0x00007f747043a32c <+236>: mov %rax,%rbx => 0x00007f747043a32f <+239>: jmpq *0x0(%rbp) 0x00007f747043a332 <+242>: cmpl $0x1b,-0x8(%rbx) 0x00007f747043a336 <+246>: jb 0x7f747043a29c <stg_BLACKHOLE_info+92> 0x00007f747043a33c <+252>: mov 0x8(%rax),%rax 0x00007f747043a340 <+256>: jmpq 0x7f747043a273 <stg_BLACKHOLE_info+51> 0x00007f747043a345 <+261>: mov %rax,%rbx 0x00007f747043a348 <+264>: jmpq *0x0(%rbp) 0x00007f747043a34b <+267>: cmpl $0xf,-0x8(%rbx) 0x00007f747043a34f <+271>: jb 0x7f747043a36d <stg_BLACKHOLE_info+301> 0x00007f747043a351 <+273>: cmpl $0x19,-0x8(%rbx) 0x00007f747043a355 <+277>: jb 0x7f747043a35d <stg_BLACKHOLE_info+285> 0x00007f747043a357 <+279>: mov %rax,%rbx 0x00007f747043a35a <+282>: jmpq *0x0(%rbp) 0x00007f747043a35d <+285>: movslq -0x8(%rbx),%rcx 0x00007f747043a361 <+289>: cmp $0x17,%rcx 0x00007f747043a365 <+293>: jne 0x7f747043a29c <stg_BLACKHOLE_info+92> 0x00007f747043a36b <+299>: jmp 0x7f747043a357 <stg_BLACKHOLE_info+279> 0x00007f747043a36d <+301>: cmpl $0x8,-0x8(%rbx) 0x00007f747043a371 <+305>: jb 0x7f747043a29c <stg_BLACKHOLE_info+92> 0x00007f747043a377 <+311>: movslq -0x8(%rbx),%rbx 0x00007f747043a37b <+315>: add $0xfffffffffffffff8,%rbx 0x00007f747043a37f <+319>: lea 0x1eca2(%rip),%rcx # 0x7f7470459028 0x00007f747043a386 <+326>: movslq (%rcx,%rbx,8),%rbx 0x00007f747043a38a <+330>: add %rbx,%rcx 0x00007f747043a38d <+333>: jmpq *%rcx End of assembler dump. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): I've got a hunch that this might be related to the use of a HashMap (from unordered-containers) inside STM transactions. I'm building my program with ordered maps from containers to see if it makes a difference. It'll take a while for the results since Nix has decided that it must rebuild GHC from my local checkout. If this is the case I think I should be able to provide a reproducible case. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): My hunch was wrong. Substituting HashMap for Map in the variable stored in a TMVar which threads contend for did not eliminate the segfaults. It made them much more frequent however. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): Another interesting segfault, again, I believe related to the same root issue: {{{ Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00007f16a46dc18b in cas (n=<optimized out>, o=596035667054922568, p=0x7f16a46fce88 <stg_upd_frame_info>) at includes/stg/SMP.h:139 139 includes/stg/SMP.h: No such file or directory. [Current thread is 1 (LWP 3885)] warning: File "/nix/store/xfrkm34sk0a13ha9bpki61l2k5g1v8dh- gcc-5.4.0-lib/lib/libstdc++.so.6.0.21-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto- load". (gdb) bt #0 0x00007f16a46dc18b in cas (n=<optimized out>, o=596035667054922568, p=0x7f16a46fce88 <stg_upd_frame_info>) at includes/stg/SMP.h:139 #1 threadPaused (cap=0x1393750, tso=0x421d9dc000) at rts/ThreadPaused.c:326 #2 0x00007f16a46fc275 in stg_returnToSched () from /nix/store/jbrmlni9jhswsdz0rfx5h5qayn8jd96r- ghc-8.2.0.20170704/lib/ghc-8.2.0.20170704/rts/libHSrts_thr_debug- ghc8.2.0.20170704.so #3 0x0000000000000000 in ?? () (gdb) up #1 threadPaused (cap=0x1393750, tso=0x421d9dc000) at rts/ThreadPaused.c:326 326 rts/ThreadPaused.c: No such file or directory. (gdb) x/64a tso->stackobj->sp 0x4217cbee88: 0x7f16a46fc5c8 <stg_enter_info> 0x420f67a2d0 0x4217cbee98: 0x7f16aaaaeba8 0x7f16aaaaeb30 0x4217cbeea8: 0xfffffffffffffffe 0x7f16a46fcf80 <stg_marked_upd_frame_info> 0x4217cbeeb8: 0x7f16a46fce88 <stg_upd_frame_info> 0x420f67a2d0 0x4217cbeec8: 0x7f16aaaaea10 <sigym4zmpropagzmenginezm0zi1zi0zi0zmFERo4wFJ8F465LTBnpBC6B_Sigym4ziPropagziEngine_zdwpolyzugo13_info+296> 0xfffffffffffffffe 0x4217cbeed8: 0x2 0x7f16aaaaf338 0x4217cbeee8: 0x420c2a39e0 0x420c2a39f8 0x4217cbeef8: 0x4201518f80 0x7f16a46fce88 <stg_upd_frame_info> 0x4217cbef08: 0x420c2a3af0 0x7f16aaade098 0x4217cbef18: 0x4220a868aa 0x420c2a3900 0x4217cbef28: 0x4220389af1 0x420bd629e9 0x4217cbef38: 0x420bd626c9 0x420c2a3969 0x4217cbef48: 0x2a3 0xfffffffffffffefa 0x4217cbef58: 0x420c1513f9 0x7f16ab5b47a0 0x4217cbef68: 0x42209c9db9 0x420c151409 0x4217cbef78: 0xffffffffffffff05 0x420bd62460 0x4217cbef88: 0x421d9ac4d9 0x421c790e93 0x4217cbef98: 0x2ab 0x4220389af1 0x4217cbefa8: 0x7f16a46fd2a0 <stg_maskAsyncExceptionszh_ret_info> 0x7f16a5026cc0 0x4217cbefb8: 0x7f16a46fd800 <stg_catch_frame_info> 0xc 0x4217cbefc8: 0x7f16a554d592 0x7f16a5026d80 0x4217cbefd8: 0x421c790eca 0x7f16a46fd800 <stg_catch_frame_info> 0x4217cbefe8: 0xc 0x7f16a5582e2a 0x4217cbeff8: 0x7f16a46fc088 <stg_stop_thread_info> 0x7f16a9f35a08 <psqueueszm0zi2zi2zi3zmE0U6TXGwkLSF0Mk5m0oV8d_DataziIntPSQziInternal_Bin_con_info> 0x4217cbf008: 0x4217cbfae1 0x4217cbfaf1 0x4217cbf018: 0x4217f8edea 0x7f16a9f7083b 0x4217cbf028: 0x6465c89002d5d36b 0x40 0x4217cbf038: 0x7f16a9f35a08 <psqueueszm0zi2zi2zi3zmE0U6TXGwkLSF0Mk5m0oV8d_DataziIntPSQziInternal_Bin_con_info> 0x42198d6069 0x4217cbf048: 0x42198d6079 0x4218bb47d2 0x4217cbf058: 0x7f16a9f7083b 0x6465c89002d5d3ab 0x4217cbf068: 0x8 0x7f16a9f35a08 <psqueueszm0zi2zi2zi3zmE0U6TXGwkLSF0Mk5m0oV8d_DataziIntPSQziInternal_Bin_con_info> 0x4217cbf078: 0x4217cbfb11 0x4217cbfb21 }}} BTW: By inspecting the stack of using {{{x/64a tso->stackobj->sp}}} I've noticed that the pointer to {{{sigym4zmpropagzmenginezm0zi1zi0zi0zmFERo4wFJ8F465LTBnpBC6B_Sigym4ziPropagziEngine_zdwpolyzugo13_info}}} is always there when it crashes. However, I cannot figure out the teh corresponding haskell function. It seems like it lives in the Sigym4.Propag.Engine but there's no function there named in a similar way to "polyzugo". I believe it could be an inlined/specialized function from another module. Any ideas on how I can I map it back to the haskell world? (I've had no success in figuring it out by reading https://ghc.haskell.org/trac/ghc/wiki/Debugging/CompiledCode) Another interesting thing is that pointers to functions from the 'psqueues' package always seem to be in the stack too when it crashes. Could be a hint on a way to build a small reproducible case. I'll continue investigating. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by hsyl20): GHC uses [https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/SymbolNames z-encoding], hence "zd" is "$" and "zu" is "_" . You can remove the `$w` prefix probably introduced by the worker/wrapper transformation, leaving you with `poly_go13` or maybe `poly_go` in the Haskell source. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:13> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): Replying to [comment:13 hsyl20]:
GHC uses [https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/SymbolNames z-encoding], hence "zd" is "$" and "zu" is "_" . You can remove the `$w` prefix probably introduced by the worker/wrapper transformation, leaving you with `poly_go13` or maybe `poly_go` in the Haskell source.
There's no function by those names in that module, however, I could manage to find "poly_go13" it's header (.hi) file. It's in a binary format which gives me no hints regarding where it might come from. Is there any way to inspect it in a more amicable way? Thanks! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): You can use the `ghc` option `--show-iface` to inspect the `.hi` file. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:15> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Also, using the gdb command `info line sigym4zmpropagzmenginezm0zi1zi0zi0zmFERo4wFJ8F465LTBnpBC6B_Sigym4ziPropagziEngine_zdwpolyzugo13_info` may also be helpful. I generally compile my programs with `-ddump-simpl -ddump-stg -ddump-opt- cmm -ddump-to-file` when looking at problems so I can refer back to what GHC was working with. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:16> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): Replying to [comment:14 albertov]:
Replying to [comment:13 hsyl20]:
GHC uses [https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/SymbolNames z-encoding], hence "zd" is "$" and "zu" is "_" . You can remove the `$w` prefix probably introduced by the worker/wrapper transformation, leaving you with `poly_go13` or maybe `poly_go` in the Haskell source.
There's no function by those names in that module, however, I could manage to find "poly_go13" it's header (.hi) file. It's in a binary format which gives me no hints regarding where it might come from. Is there any way to inspect it in a more amicable way? Thanks!
I've found out by compiling with {{{-ddump-simpl}}} that {{{poly_go13}}} seems to be a specialization of {{{Data.Map.lookup}}}: {{{ $wpoly_go13 [InlPrag=[0], Occ=LoopBreaker] :: forall a. Int# -> Int# -> Map BlockIndex a -> Maybe a [GblId, Arity=3, Caf=NoCafRefs, Str=<L,U><L,U><S,1*U>] $wpoly_go13 = \ (@ a) (ww :: Int#) (ww1 :: Int#) (w :: Map BlockIndex a) -> case w of { Bin ipv ipv1 ipv2 ipv3 ipv4 -> case ipv1 of { V2 b1 b2 -> case b1 of { I# y# -> case b2 of { I# y#1 -> case tagToEnum# @ Bool (<# ww y#) of { False -> case tagToEnum# @ Bool (==# ww y#) of { False -> $wpoly_go13 @ a ww ww1 ipv4; True -> case tagToEnum# @ Bool (<# ww1 y#1) of { False -> case tagToEnum# @ Bool (==# ww1 y#1) of { False -> $wpoly_go13 @ a ww ww1 ipv4; True -> Just @ a ipv2 }; True -> $wpoly_go13 @ a ww ww1 ipv3 } }; True -> $wpoly_go13 @ a ww ww1 ipv3 } } } }; Tip -> Nothing @ a } end Rec } }}} where {{{ type BlockIndex = Linear.V2.V2 Int }}} I can relate to the part of my program where this comes from and, interestingly, this was originally a {{{Data.HashMap.Strict.HashMap}}} which I changed to a {{{Data.Map.Strict.Map}}} to see if it made a difference (see comment:10). For some reason, segfaults are much more frequent with the Data.Map (so I've left it like this to help debug). This Map is stored in a TMVar which threads regularly {{{M.lookup blockIx <$> readTMVar}}} neighboring Blocks to send them "work". When the lookup fails they take the lock, create a new Block and a new thread to process it, put the Block back in the Map and put the Map back in the TMVar. So, although the BlockIndex is strict, the value isn't so perhaps this is where shared un-evaluated thunks are created which manifests the bug? (if my intuition about the problem is correct). Anyway, now I have some ideas on how to attempt to reproduce this bug outside of my program, which might be quicker than factoring out the whole engine out of the propietary parts. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:17> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari):
Anyway, now I have some ideas on how to attempt to reproduce this bug outside of my program, which might be quicker than factoring out the whole engine out of the propietary parts.
I agree; it would be great if you could extract the essence of the issue into an independent repro. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:18> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): After removing many dependencies and some cleanup we've opensourced the engine of the problematic wildfire simulator. Fortunately the bug still manifests itself (which rules out some kind of nasty interaction with the foreign libraries it linked to). To reproduce clone https://github.com/meteogrid/propag , `cabal new-build` it and run the `propag-demo` executable. Using the rc3 pre-release and running with `+RTS -N12` it crashed 100% of the times I've tried (the refactor has increased the change of crash). Sorry for this monster of a reproducible case. It's the best I could do to minimize the amount of third-party dependencies for the time being. I'm planning to remove the dependency on the wildfire-specific stuff which should remove more dependencies (and make it useful as an arbitrary 2D spread automata). I've tried initially to reproduce it starting from scratch but did not succeed so I pulled out all the bigger dependencies (eg: meteogrid/bindings-gdal) which require bindings to c++ libraries. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:19> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Thanks albertov! I'm building your repro as we speak. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:20> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): Replying to [comment:20 bgamari]:
Thanks albertov! I'm building your repro as we speak.
Thanks! Did you manage to reproduce the segfault? By the way, I forgot to warn you that this creates a temporary work directory using `System.IO.Temp.withSystemTempDirectory` named `propag-work-XXXX`. It is mean to be cleared after running but if it crashes it wont be so make sure you clean them as they can add up to a lot of space after many experiments. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:21> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): I have managed to reproduce it a few times although it does seem to take a while. Moreover, it (perhaps not surprisingly) is quite dependent upon paralellism. I was unable to reproduce it in a reasonable amount of time on my dual-core, four-thread laptop. However, on my 4-core, eight-thread server I was able to reproduce it within ten minutes or so. How many cores does your test environment have? Also, for the sake of My first step is to test whether the fix to #13615 is to blame; the problem indeed appears to be a race condition and instrumenting the code can easily hide the problem. For instance, I was unable to reproduce the issue even once while running the program under `rr` overnight. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:22> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): Replying to [comment:22 bgamari]:
I have managed to reproduce it a few times although it does seem to take a while. Moreover, it (perhaps not surprisingly) is quite dependent upon paralellism. I was unable to reproduce it in a reasonable amount of time on my dual-core, four-thread laptop. However, on my 4-core, eight-thread server I was able to reproduce it within ten minutes or so. How many cores does your test environment have?
I'm testing on a 6-core, 12-thread machine. It is indeed hard to reproduce although it is no much more frequent. I've noticed that giving a large `-N` value to the RTS increases the odds. I'm testing with `-N30`. Have you tried increasing this value way over your number of cores? Another interesting thing is that without this [https://github.com/meteogrid/propag/blob/master/app/Main.hs#L69 pause] I was unable to reproduce the crash and noticed that a breakpoint I had set at `suspendComputation` was never being hit. Adding this pause causes `suspendComputation` to be called multiple times and eventually manifests the problem (when running outside gdb). Maybe playing with that pause helps increasing the odds in your environment? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:23> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): Reducing the block size [https://github.com/meteogrid/propag/blob/master/app/Main.hs#L33 here] (to an even number) should also help increasing the odds of a crash since the program will create more (non-OS) threads -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:24> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): I have confirmed that c1c0985416a6f9766c03d361449f556905bf8e1d really is the first bad commit. I also noticed that it is possible to reproduce the crash using `forkIO` instead of `forkOS`, which makes it a bit easier to debug. Presumably this is safe since there are no native dependencies. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:25> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: patch Priority: highest | Milestone: 8.2.1 Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * priority: normal => highest * status: new => patch * milestone: => 8.2.1 Comment: I found the issue. I neglected to consider that the stack-pointer adjustment in the `AP_STACK` entry code also accounted for the words that we would later copy from the applied stack to the current thread's stack. Since the stack-pointer adjustment happened before we attempted to blackhole the `AP_STACK` closure, there was a small chance that we would suspend the thread with uninitialized content on its stack (specifically, if another thread beat us to blackholing the closure). This should be fixed by Phab:D3760. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:26> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: patch Priority: highest | Milestone: 8.2.1 Component: Runtime System | Version: 8.2.1-rc3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"bade356f79d44c9f6e8918a89d9ffac7f5608dbf/ghc" bade356/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="bade356f79d44c9f6e8918a89d9ffac7f5608dbf" rts: Claim AP_STACK before adjusting Sp In the fix to #13615 we introduced some logic to atomically blackhole AP_STACKs closures upon entry. However, this logic was placed *after* a stack pointer adjustment. This meant that if someone else beat us to blackholing the AP_STACK we would suspend the thread with uninitialized content on the stack. This would then later blow up when threadPaused attempted to walk the stack, hence #13970. Silly bug but still cost lots of head-scratching to find. Thanks to albertov for the great repro. Fixes #13970. Bug originally introduced by the fix to #13615. Reviewers: austin, erikd, simonmar Reviewed By: erikd, simonmar Subscribers: rwbarton, thomie GHC Trac Issues: #13970, #13615 Differential Revision: https://phabricator.haskell.org/D3760 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:27> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: closed Priority: highest | Milestone: 8.2.1 Component: Runtime System | Version: 8.2.1-rc3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed Comment: Merged to `ghc-8.2` with ffea6cfe7137093c32cd2357fb9fdf9db9430543. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:28> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: closed Priority: highest | Milestone: 8.2.1 Component: Runtime System | Version: 8.2.1-rc3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by albertov): Amazing. I'm building a new ghc right now to test it. Sorry I couldn't do it before, I didn't expect it to be fixed so quickly! Thanks bgamari! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:29> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: closed Priority: highest | Milestone: 8.2.1 Component: Runtime System | Version: 8.2.1-rc3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mnislaih): Hey, thanks a lot to everyone who reported, worked and ultimately fixed this bug. We (Barclays) only got around to test RC3 yesterday and found that it was nigh impossible to build our code base with it in our Windows environment. Today I built GHC from the 8.2 branch with this fix included and it's all good again. Thanks again! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:30> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13970: Segmentation fault inside threadPaused -------------------------------------+------------------------------------- Reporter: albertov | Owner: (none) Type: bug | Status: closed Priority: highest | Milestone: 8.2.1 Component: Runtime System | Version: 8.2.1-rc3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): I'm glad it helped! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13970#comment:31> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC