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.
@omerfirmak updated dlang/druntime pull request #3418 "Allow detached threads to be joined" fixing this issue: - Fix Issue 21784: Allow detached threads to be joined This is useful when a thread terminates before the caller is able to join(). https://github.com/dlang/druntime/pull/3418
dlang/druntime pull request #3418 "Fix Issue 21784: Allow detached threads to be joined" was merged into stable: - b301faf42df1bfab60ada38473dd46000c1fdf66 by Ömer Faruk Irmak: Fix Issue 21784: Allow detached threads to be joined This is useful when a thread terminates before the caller is able to join(). https://github.com/dlang/druntime/pull/3418
dlang/druntime pull request #3434 "merge stable" was merged into master: - c5eb299128d7614e18ee2e2366005843dbeb0c6b by Ömer Faruk Irmak: Fix Issue 21784: Allow detached threads to be joined This is useful when a thread terminates before the caller is able to join(). https://github.com/dlang/druntime/pull/3434