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 |
A blocking function is called while a lock is held.
| Class Name | Blocking in Critical Section | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Significance | reliability | |||||||||
| Mnemonic | CONCURRENCY.STARVE.BLOCKING | |||||||||
| Categories |
|
|||||||||
| Availability | Available for C and C++. |
|||||||||
| Enabling | Checks for this warning class are enabled by
default. To disable them, add the following WARNING_FILTER rule to the
project configuration file.
WARNING_FILTER += discard class="Blocking in Critical Section" |
The code calls a blocking function while holding one or more locks, where:
| a blocking function | Any function treated as a blocking function by CodeSonar:
|
|---|---|
| a thread holds lock L |
if it has acquired L with one of the following, but not yet
released it.
|
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
void concurrency_starve_blocking(pthread_mutex_t lock){
sleep(2); /* ok: No lock held at this time */
if( pthread_mutex_lock(&lock) != 0 ){
abort();
}
sleep(3); /* 'Blocking in Critical Section' warning issued here
* - a lock is held while the thread blocks.
*/
if( pthread_mutex_unlock(&lock) != 0 ) abort();
sleep(4); /* ok: No lock held at this time */
}
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.