Opened 17 years ago
Last modified 4 years ago
#654 new enhancement
Check for async-signal-unsafe functions
| Reported by: | Markus Elfring | Owned by: | noone |
|---|---|---|---|
| Priority: | Normal | Milestone: | |
| Component: | New check | Version: | |
| Keywords: | signalHandler atomicDataAccess | Cc: | php-coderrr, Kamil Dudka |
Description (last modified by )
A signal handler implementation must adhere to strict requirements.
- The list of functions that may be called is limited.
- A recommended data type for access to global variables is sig_atomic_t.
Would you like to add a search capability for the property "async-signal-safety" in the source files if the rules were broken?
Change History (8)
comment:1 by , 17 years ago
| Cc: | added |
|---|
comment:2 by , 13 years ago
| Cc: | added |
|---|---|
| Priority: | → Normal |
follow-up: 5 comment:3 by , 13 years ago
comment:4 by , 9 years ago
| Component: | New check → Other |
|---|---|
| Keywords: | signalHandler atomicDataAccess added; signal handler atomic data access removed |
comment:5 by , 9 years ago
| Description: | modified (diff) |
|---|
Replying to amai:
That might be useful, though quite difficult to implement in cppcheck:
- The signal handler has to be registered in the same source than the handler is implemented /defined - so cppcheck can analyze
Ok, that requirement got removed recently. The whitelist is available within the given external resource.
comment:6 by , 4 years ago
| Component: | Other → New check |
|---|
comment:7 by , 4 years ago
FYI clang-tidy has the bugprone-signal-handler check nowadays and is soon landing some major improvements to it.
See
https://clang.llvm.org/extra/clang-tidy/checks/bugprone/signal-handler.html
https://reviews.llvm.org/D118996
comment:8 by , 4 years ago
The GCC analyzer also checks for this programming mistake: https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Static-Analyzer-Options.html#index-Wno-analyzer-unsafe-call-within-signal-handler
That might be useful, though quite difficult to implement in cppcheck: