Shared data access within signal handler
Access or modification of shared data causes inconsistent state
Description
This defect occurs when you access or modify a shared object inside a signal handler.
Risk
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.
Fix
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
.
Examples
Result Information
Group: Programming |
Language: C | C++ |
Default: On for handwritten code, off for generated code |
Command-Line Syntax:
SIG_HANDLER_SHARED_OBJECT
|
Impact: Medium |
Version History
Introduced in R2017b
See Also
Function called from
signal handler not asynchronous-safe
| Signal call from within
signal handler
| Find defects (-checkers)
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)