]> git.ipfire.org Git - thirdparty/gcc.git/commit
analyzer: fix apparent hang with -fanalyzer-verbosity=0 [PR analyzer/99886]
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 5 Apr 2021 14:48:01 +0000 (10:48 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 5 Apr 2021 14:48:01 +0000 (10:48 -0400)
commit69b66ff02353a87585329bb3cf4ac20d6dee1b16
treed65789a51f9c7a14f4b6fcf0f13a157d8a680bd8
parentbd89b8fe9efbdf0a95d827553d1a84fd3cefaa16
analyzer: fix apparent hang with -fanalyzer-verbosity=0 [PR analyzer/99886]

The analyzer appeared to enter an infinite loop on malloc-1.c
when -fanalyzer-verbosity=0 was used.  In fact, it was slowly
counting from 0 to 0xffffffff.

Root cause is looping up to effectively ((unsigned)0) - 1 in
diagnostic_manager::consolidate_conditions when there are no events
in the path.

Fixed by the following, which uses signed integers when subtracting
from path->num_events () when simplifying checker_paths.

gcc/analyzer/ChangeLog:
PR analyzer/99886
* diagnostic-manager.cc
(diagnostic_manager::prune_interproc_events): Use signed integers
when subtracting one from path->num_events ().
(diagnostic_manager::consolidate_conditions): Likewise.  Convert
next_idx to a signed int.

gcc/testsuite/ChangeLog:
PR analyzer/99886
* gcc.dg/analyzer/pr99886.c: New test.
gcc/analyzer/diagnostic-manager.cc
gcc/testsuite/gcc.dg/analyzer/pr99886.c [new file with mode: 0644]