Thread that was previously joined or detached is joined or detached again
This defect occurs when:
You try to join a thread that was previously joined or detached.
You try to detach a thread that was previously joined or detached.
The Result Details pane describes if the thread was previously joined or detached and also shows previous related events.
For instance, a thread joined with thrd_join is then detached with
thrd_detach:
thrd_t id; ... thrd_join(id, NULL); thrd_detach(id);
Note that a thread is considered as joined only if a previous thread joining is successful.
For instance, the thread is not considered as joined in the if branch
here:
thrd_t t;
...
if (thrd_success != thrd_join(t, 0)) {
/* Thread not considered joined */
}thrd_current() function.The C11 standard (clauses 7.26.5.3 and 7.26.5.6) states that a thread shall not be joined or detached once it was previously joined or detached. Violating these clauses of the standard results in undefined behavior.
Avoid joining a thread that was already joined or detached previously. Avoid detaching a thread that was already joined or detached.
| Group: Concurrency |
| Language: C |
| Default: Off |
Command-Line Syntax:
DOUBLE_JOIN_OR_DETACH |
| Impact: Medium |