[Issue 19314] New: Thread object destruction may result in UB

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 19 13:06:50 UTC 2018


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 at puremagic.com
          Reporter: mihails.strasuns at 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`).

--


More information about the Digitalmars-d-bugs mailing list