 
                            Mutexes are used to protect shared data structures being concurrently accessed. If a mutex is destroyed while a thread is blocked waiting for that mutex, critical sections and shared data are no longer protected.
The C Standard, 7.2628.4.1, paragraph 2 [ISO/IEC 9899:20112024], states
The
mtx_destroyfunction releases any resources used by the mutex pointed to bymtx. No threads can be blocked waiting for the mutex pointed to bymtx.
...
Destroying a mutex while it is locked may result in invalid control flow and data corruption.
| Rule | Severity | Likelihood | Detectable | RepairableRemediation Cost | Priority | Level | 
|---|---|---|---|---|---|---|
| CON31-C | Medium | Probable | No | HighNo | P4 | L3 | 
Automated Detection
| Tool | Version | Checker | Description | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Astrée | 
 | Supported, but no explicit checker | ||||||||||||
| CodeSonar | 
 | CONCURRENCY.LOCALARG | Local Variable Passed to Thread | |||||||||||
| Cppcheck Premium | 
 | premium-cert-con31-c | ||||||||||||
| Helix QAC | 
 | DF4961, DF4962 | ||||||||||||
| Parasoft C/C++test | 
 | CERT_C-CON31-a | Do not destroy another thread's mutex | |||||||||||
| Destruction
 | CERT C: Rule CON31-C | Checks for destruction of locked mutex | Task tries to destroy a mutex in the locked state | (rule fully covered) | 
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...
Bibliography
| [ISO/IEC 9899:20112024] | 7.2628.4.1, "The mtx_destroyFunction" | 
...