sqc 0.4.13

Software Code Quality - CERT C compliance checker
[metadata]
id = "POS53-C"
type = "rule"
category = "POS"
number = 53
title = "Do not use more than one mutex for concurrent waiting operations on a condition variable"
description = """
pthread_cond_wait()andpthread_cond_timedwait()take a condition variable and
locked mutex as arguments. These functions unlock the mutex until the condition
variable is signaled and then relock the mutex before returning. While a thread
is waiting on a particular condition variable and mutex, other threads may only
wait on the same condition variable if they also pass the same mutex as an
argument. This requirement is noted in theOpen Group Base Specifications, Issue
6: It also specifies thatpthread_cond_wait()may€ fail if: In this noncompliant
code example,mutex1protectscount1andmutex2protectscount2. Arace conditionexists
between thewaiter1andwaiter2threads because they use the same condition variable
with different mutexes. If both threads attempt to callpthread_cond_wait()at the
same time, one thread will succeed and the other thread will invokeundefined
behavior.
"""
severity = "Medium"
likelihood = "Probable"
priority = "P8"
level = "L2"
cert_version = "2016 Edition (Wiki)"
last_modified = "May 06, 2025"

[rules.cert_c.POS53-C]
enabled = true

[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/POS53-C.+Do+not+use+more+than+one+mutex+for+concurrent+waiting+operations+on+a+condition+variable"