digitalmars.D.bugs - [Issue 21784] New: joining a detached thread results in segfault.
- d-bugmail puremagic.com (34/34) Mar 30 2021 https://issues.dlang.org/show_bug.cgi?id=21784
https://issues.dlang.org/show_bug.cgi?id=21784 Issue ID: 21784 Summary: joining a detached thread results in segfault. Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: druntime Assignee: nobody puremagic.com Reporter: omerfirmak gmail.com import core.thread; import core.sync.semaphore; __gshared Semaphore sem; void thread_main () { sem.notify(); } void main() { auto th = new Thread(&thread_main); sem = new Semaphore(); th.start(); sem.wait(); while (th.isRunning()) {} destroy(th); // force detach th.join(); } Above piece of code will segfault since the dtor of the Thread will reset m_addr and Thread.join() will pass that null value to phread_join() without checking if it is valid. --
Mar 30 2021