MISRA C:2023 Rule 22.11
A thread that was previously either joined or detached shall not be subsequently joined nor detached
Since R2024b
Description
This checker is deactivated in a default Polyspace® as You Code analysis. See Checkers Deactivated in Polyspace as You Code Analysis (Polyspace Access).
Rule Definition
A thread that was previously either joined or detached shall not be subsequently joined nor detached.
Rationale
The C11 standard (subclauses 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 subclauses of the standard results in undefined behavior.
Polyspace Implementation
Polyspace reports a violation of this rule 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 shows whether the thread was previously joined or detached and also shows previous related events.
Polyspace considers a thread joined only if a previous thread joining was
successful. For instance, the thread t
is not considered joined in
the body of the if
branch:
thrd_t t; ... if (thrd_success != thrd_join(t, 0)) { /* Thread not considered joined */ }
thrd_current()
function.Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Resources |
Category: Required |
AGC Category: Required |
Version History
Introduced in R2024b