JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++
Binaries


CONCURRENCY.BADFUNC.CNDSIGNAL : Use of Condition Variable Signal

要旨

A use of a function such as pthread_cond_signal() to unblock a thread that is blocked on a condition variable. This can lead to concurrency problems if multiple threads are sharing a condition variable.

If you get a warning of this class, check to make sure that all threads are using separate, unique condition variables. If so (and your organization has not forbidden the use of these functions), you can ignore the warning, for example by setting its Priority to Suppressed.

See also Use of Condition Variable Wait.

プロパティ

クラス名 Use of Condition Variable Signal
日本語クラス名 Use of Condition Variable Signal
クラス分類 信頼性 (reliability)
ニーモニック CONCURRENCY.BADFUNC.CNDSIGNAL
カテゴリー
CWE CWE:676 Use of Potentially Dangerous Function
CERT-C CERT-C:CON38-C Preserve thread safety and liveness when using condition variables
CERT-CPP CERT-CPP:CON55-CPP Preserve thread safety and liveness when using condition variables
OWASP-2021 OWASP-2021:A4 Insecure design
OWASP-2025 OWASP-2025:A06 Insecure Design
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Use of Condition Variable Signal"

#include <pthread.h>

pthread_mutex_t lock;
pthread_cond_t cond;
unsigned int test;

void make_test_false(void)
{
    pthread_mutex_lock(&lock);
    while (test == 0)
        pthread_cond_wait(&cond, &lock);                     /* 'Use of Condition Variable Wait' warning issued here */
    test = 0;
    pthread_mutex_unlock(&lock);
}

void make_test_true(void)
{
    pthread_mutex_lock(&lock);
    if (test == 0)
        pthread_cond_signal(&cond);      /* 'Use of Condition Variable Signal' warning issued here */
    test = 1;
    pthread_mutex_unlock(&lock);
}

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。

 

To report problems with this documentation, please visit https://support.codesecure.com/.