[0/7,analyzer] Add checking for unsafe calls within signal handlers

Message ID 20191204162530.9285-1-dmalcolm@redhat.com
Headers show
Series
  • Add checking for unsafe calls within signal handlers
Related show

Message

David Malcolm Dec. 4, 2019, 4:25 p.m.
This patch kit adds a new warning:
  -Wanalyzer-unsafe-call-within-signal-handler
to the analyzer branch.

A colorized example of the output can be seen here:
  https://dmalcolm.fedorapeople.org/gcc/2019-12-04/signal.c.html

Currently it only detects calls to "fprintf".

This is a new feature beyond what I posted before the stage 1 deadline
- but what I posted already contained a couple of proof-of-concept
checkers.

For now I'm pushing it to the branch, since that seems better than having
it just on my hard drive; the supporting patches also contain
generalizations of the code that I think are likely to be useful for
future work (e.g. supporting C++ exceptions).

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.

Pushed to branch "dmalcolm/analyzer" on the GCC git mirror.

Dave


David Malcolm (7):
  [analyzer] Support paths for callbacks
  [analyzer] More test coverage
  [analyzer] Generalize rewind_info_t to exploded_edge::custom_info_t
  [analyzer] Support global states and custom transitions
  [analyzer] Support custom events
  [analyzer] Expose state_change_event in evdesc::state_change
  [analyzer] Add -Wanalyzer-unsafe-call-within-signal-handler

 gcc/analyzer/Make-plugin.in                   |   1 +
 gcc/analyzer/analyzer.h                       |   2 +
 gcc/analyzer/checker-path.cc                  |  62 +++-
 gcc/analyzer/checker-path.h                   |  40 ++-
 gcc/analyzer/diagnostic-manager.cc            | 135 +++++---
 gcc/analyzer/engine.cc                        | 143 ++++++--
 gcc/analyzer/exploded-graph.h                 |  85 +++--
 gcc/analyzer/pending-diagnostic.h             |   8 +-
 gcc/analyzer/plugin.opt                       |   4 +
 gcc/analyzer/program-state.cc                 |  38 ++-
 gcc/analyzer/program-state.h                  |  11 +
 gcc/analyzer/sm-signal.cc                     | 304 ++++++++++++++++++
 gcc/analyzer/sm.cc                            |   1 +
 gcc/analyzer/sm.h                             |  24 ++
 gcc/doc/invoke.texi                           |  13 +
 gcc/testsuite/gcc.dg/analyzer/data-model-1.c  |   6 +
 gcc/testsuite/gcc.dg/analyzer/signal-1.c      |  31 ++
 gcc/testsuite/gcc.dg/analyzer/signal-2.c      |  34 ++
 gcc/testsuite/gcc.dg/analyzer/signal-3.c      |  23 ++
 gcc/testsuite/gcc.dg/analyzer/signal-4a.c     |  74 +++++
 gcc/testsuite/gcc.dg/analyzer/signal-4b.c     |  89 +++++
 .../gcc.dg/plugin/diagnostic-test-paths-4.c   |  83 +++++
 .../plugin/diagnostic_plugin_test_paths.c     |  81 +++++
 gcc/testsuite/gcc.dg/plugin/plugin.exp        |   1 +
 gcc/tree-diagnostic-path.cc                   |  75 +++--
 25 files changed, 1201 insertions(+), 167 deletions(-)
 create mode 100644 gcc/analyzer/sm-signal.cc
 create mode 100644 gcc/testsuite/gcc.dg/analyzer/signal-1.c
 create mode 100644 gcc/testsuite/gcc.dg/analyzer/signal-2.c
 create mode 100644 gcc/testsuite/gcc.dg/analyzer/signal-3.c
 create mode 100644 gcc/testsuite/gcc.dg/analyzer/signal-4a.c
 create mode 100644 gcc/testsuite/gcc.dg/analyzer/signal-4b.c
 create mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-4.c

-- 
2.21.0