digitalmars.D.bugs - [Issue 19314] New: Thread object destruction may result in UB
- d-bugmail puremagic.com (22/22) Oct 19 2018 https://issues.dlang.org/show_bug.cgi?id=19314
https://issues.dlang.org/show_bug.cgi?id=19314 Issue ID: 19314 Summary: Thread object destruction may result in UB Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: druntime Assignee: nobody puremagic.com Reporter: mihails.strasuns gmail.com Split from https://issues.dlang.org/show_bug.cgi?id=19288 Expectation is that after thread is detached from druntime, it becomes responsibility of external environment to terminate it properly (for example, by calling `join` from C/C++ code). However, `Thread` object for that thread will still remain and will eventually be collected by GC. Destructor tries to call `pthread_detach` unconditionally but it is undefined behaviour if thread was alread joined before (see `man pthread_detach`). --
Oct 19 2018