From f7decfaebbcb8522fcb39b03a391a5c2cb64f460 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 22 Oct 2020 06:16:28 -0400 Subject: [PATCH] analyzer: fix ICE when handling callback exceeds enode limit [PR97514] gcc/analyzer/ChangeLog: PR analyzer/97514 * engine.cc (exploded_graph::add_function_entry): Handle failure to create an enode, rather than asserting. gcc/testsuite/ChangeLog: PR analyzer/97514 * gcc.dg/analyzer/pr97514.c: New test. --- gcc/analyzer/engine.cc | 5 +++-- gcc/testsuite/gcc.dg/analyzer/pr97514.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/analyzer/pr97514.c diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index b1c877e5231..d4c654a3497 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -1956,8 +1956,9 @@ exploded_graph::add_function_entry (function *fun) return NULL; exploded_node *enode = get_or_create_node (point, state, NULL); - /* We should never fail to add such a node. */ - gcc_assert (enode); + if (!enode) + return NULL; + add_edge (m_origin, enode, NULL); m_functions_with_enodes.add (fun); diff --git a/gcc/testsuite/gcc.dg/analyzer/pr97514.c b/gcc/testsuite/gcc.dg/analyzer/pr97514.c new file mode 100644 index 00000000000..27245f442bc --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/pr97514.c @@ -0,0 +1,18 @@ +/* { dg-additional-options "--param analyzer-max-enodes-per-program-point=0 -Wno-analyzer-too-complex" } */ + +typedef void (*sighandler_t) (int); + +void +signal (int, sighandler_t); + +static void +kw (int signum) +{ + (void) signum; +} + +void +gk (int ot) +{ + signal (ot, kw); +} -- 2.30.2