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 |
Different threads acquire the same locks in different orders. This can lead to deadlock or other undefined behavior.
| Class Name | Conflicting Lock Order | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | reliability | |||||||||||||||||||||||||||
| Mnemonic | CONCURRENCY.LOCK.ORDER | |||||||||||||||||||||||||||
| Categories |
|
|||||||||||||||||||||||||||
| Availability | Available for C and C++. |
|||||||||||||||||||||||||||
| Enabling | Checks for this warning class are
disabled by default. To enable them, add the following WARNING_FILTER
rule to the project configuration file.
WARNING_FILTER += allow class="Conflicting Lock Order" |
Conflicting Lock Order warnings can be triggered by the following functions.
#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); }
In a multithreaded environment, two threads could try to obtain the two locks in different orders, possibly resulting in deadlock:
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.