Can you reproduce this threading bug?
Jacob Carlborg
doob at me.com
Fri Jun 14 18:58:52 UTC 2019
On 2019-06-14 18:36, FeepingCreature wrote:
> Consider the following code:
>
> void main()
> {
> import core.thread : Thread;
>
> with (new Thread({ })) { isDaemon = true; start; }
> }
>
> On Linux, this builds and runs. Most of the time. Maybe 99% of the time.
>
> But if you run it in a loop:
>
> while true; do ./test || break; done
>
> You may see that it segfaults after a few seconds. At least, it does for
> me on 2.080.0, Linux 4.18.0-20 x86_64.
>
> This is obviously quite bad. Any ideas?
On macOS I get a mixture of the following:
Aborting from src/core/sync/mutex.d(149) Error: pthread_mutex_destroy
failed.Abort trap: 6
Aborting from src/core/sync/mutex.d(149) Error: pthread_mutex_destroy
failed.Segmentation fault: 11
Aborting from Segmentation fault: 11
Pretty easy to reproduce. But when I tried in a debugger I failed to
reproduce the segfault. Although, here is what the crash reporter logged:
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff4fe8cb66 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff50057080 pthread_kill + 333
2 libsystem_c.dylib 0x00007fff4fde81ae abort + 127
3 main 0x00000001033978e2
_D4core8internal5abortQgFNbNiNfMAyaMQemZv + 262
4 main 0x0000000103394e73 thread_term + 259
5 main 0x00000001033a7268 rt_term + 88
6 main 0x00000001033a796c
_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 208
7 main 0x00000001033a7848
_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 36
8 main 0x00000001033a77a8 _d_run_main + 764
9 main 0x0000000103384e72 main + 34
10 libdyld.dylib 0x00007fff4fd3c015 start + 1
Thread 1:
0 main 0x0000000103394ab3
_D4core6thread6Thread6removeFNbNiCQBgQBeQBaZv + 63
1 main 0x0000000103393922 thread_entryPoint
+ 526
2 libsystem_pthread.dylib 0x00007fff50054661 _pthread_body + 340
3 libsystem_pthread.dylib 0x00007fff5005450d _pthread_start + 377
4 libsystem_pthread.dylib 0x00007fff50053bf9 thread_start + 13
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00007fff88782380 rcx:
0x00007ffeec87b158 rdx: 0x0000000000000000
rdi: 0x0000000000000307 rsi: 0x0000000000000006 rbp:
0x00007ffeec87b190 rsp: 0x00007ffeec87b158
r8: 0x000000000000000a r9: 0x0000000000000011 r10:
0x0000000000000000 r11: 0x0000000000000206
r12: 0x0000000000000307 r13: 0x00007ffeec87b3c6 r14:
0x0000000000000006 r15: 0x000000000000002d
rip: 0x00007fff4fe8cb66 rfl: 0x0000000000000206 cr2: 0x000000010343d088
Logical CPU: 6
Error Code: 0x00000004
Trap Number: 14
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list