Access or modification of shared data causes inconsistent state
This defect occurs when you access or modify a shared object inside a signal handler.
When you define a signal handler function to access or modify a shared object, the handler accesses or modifies the shared object when it receives a signal. If another function is already accessing the shared object, that function causes a race condition and can leave the data in an inconsistent state.
To access or modify shared objects inside a signal handler, check that the objects are
lock-free atomic, or, if they are integers, declare them as volatile
sig_atomic_t.
| Group: Programming |
| Language: C | C++ |
| Default: On for handwritten code, off for generated code |
Command-Line Syntax:
SIG_HANDLER_SHARED_OBJECT
|
| Impact: Medium |
| CWE ID: 364, 413 |
Find defects (-checkers) | Function called from
signal handler not asynchronous-safe | Signal call from within
signal handler