digitalmars.D.bugs - [Issue 13330] New: Calling std.c.stdlib.exit() from child threads
- via Digitalmars-d-bugs (60/60) Aug 18 2014 https://issues.dlang.org/show_bug.cgi?id=13330
https://issues.dlang.org/show_bug.cgi?id=13330 Issue ID: 13330 Summary: Calling std.c.stdlib.exit() from child threads causes segfault Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: andrei erdani.com 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 --
Aug 18 2014