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.0p0 Hot Tips | CONFIDENTIAL | CodeSecure Inc |
異なったスレッドが異なった順番で同じロックを取得しました。 これはデッドロックもしくは未定義動作の原因となります。
| クラス名 | Conflicting Lock Order | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | ロック順序の不一致 | ||||||||||||||||||||||||
| クラス分類 | 信頼性 (reliability) | ||||||||||||||||||||||||
| ニーモニック | CONCURRENCY.LOCK.ORDER | ||||||||||||||||||||||||
| カテゴリー |
|
||||||||||||||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
||||||||||||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Conflicting Lock Order" |
以下のどの関数でも引き起こされます。
#include <pthread.h> pthread_mutex_t Green; pthread_mutex_t Blue; /* ----- Thread 1 ----- */ void green_before_blue(void){ pthread_mutex_lock(&Green); /* Green acquired before Blue */ pthread_mutex_lock(&Blue); /* 'Conflicting Lock Order' warning issued either here or in marked location below */ /* ... operate on locked data */ pthread_mutex_unlock(&Blue); pthread_mutex_unlock(&Green); } /* ----- Thread 2 ----- */ void blue_before_green(void){ pthread_mutex_lock(&Blue); /* Blue acquired before Green */ pthread_mutex_lock(&Green); /* 'Conflicting Lock Order' warning issued either here or in marked location above */ /* ... operate on locked data */ pthread_mutex_unlock(&Green); pthread_mutex_unlock(&Blue); }
マルチスレッド環境で2つのスレッドが2つのロックを異なった順序で獲得しようとした場合、デッドロックになる可能性があります。
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。