Bug 13330 – Calling std.c.stdlib.exit() from child threads causes segfault

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2014-08-18T22:54:42Z
Last change time
2019-12-13T22:39:19Z
Assigned to
No Owner
Creator
Andrei Alexandrescu

Comments

Comment #0 by andrei — 2014-08-18T22:54:42Z
Repro program: import std.stdio, std.concurrency; static void thread_run() { int[int] testMap; // should throw an out of range exception writeln("child: running ..."); try { int testValue = testMap[10]; } catch(Throwable e) { writefln("Exception in child thread: %s", e); std.c.stdlib.exit(0); } writeln("child: testValue set, sent back to parent"); ownerTid.send(1); } int main() { writeln("partent: starting child thread ..."); Tid child = spawn(&thread_run); int stop = 0; while(stop <= 0) { stop = receiveOnly!int(); writefln("parent: received from child: %s, exiting...", stop); } writeln("exiting"); return 0; } OUTPUT: [ghwang@dev1817 ~/test] ./testException partent: starting child thread ... child: running ... Exception in child thread: core.exception.RangeError@testException(8): Range violation ---------------- ./testException(_d_array_bounds+0x26) [0x48f3a6] ./testException() [0x46d17e] ./testException(void testException.thread_run()+0x6a) [0x46214e] ./testException(_D3std11concurrency16__T6_spawnTPFZvZ6_spawnFbPFZvZS3std11concurrency3Tid4execMFZv+0x3d) [0x465761] ./testException(void core.thread.Thread.run()+0x2a) [0x49a306] ./testException(thread_entryPoint+0x165) [0x49a08d] /usr/local/fbcode/gcc-4.8.1-glibc-2.17-fb/lib/libpthread.so.0(+0x7fa8) [0x7fa5256adfa8] /usr/local/fbcode/gcc-4.8.1-glibc-2.17-fb/lib/libc.so.6(clone+0x6d) [0x7fa524ec35ad] Segmentation fault
Comment #1 by moonlightsentinel — 2019-12-13T22:39:19Z
Not reproducible with 2.089.0