From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7853) id 8A835385841E; Wed, 25 Aug 2021 07:07:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A835385841E Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ankur saini To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/arsenic/heads/analyzer_extension)] analyzer: Impose recursion limit on indirect calls. X-Act-Checkin: gcc X-Git-Author: Ankur Saini X-Git-Refname: refs/users/arsenic/heads/analyzer_extension X-Git-Oldrev: db3d4129b6f4cff685713da514b64ff7bbc401fc X-Git-Newrev: c846bf7b58d8c87548515b363d3cef5fc544e390 Message-Id: <20210825070752.8A835385841E@sourceware.org> Date: Wed, 25 Aug 2021 07:07:52 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 07:07:52 -0000 https://gcc.gnu.org/g:c846bf7b58d8c87548515b363d3cef5fc544e390 commit c846bf7b58d8c87548515b363d3cef5fc544e390 Author: Ankur Saini Date: Wed Aug 25 12:33:06 2021 +0530 analyzer: Impose recursion limit on indirect calls. 2021-08-25 Ankur Saini gcc/analyzer/ChangeLog: PR analyzer/101980 * engine.cc (exploded_graph::maybe_create_dynamic_call): Don't create calls if max recursion limit is reached. Diff: --- gcc/analyzer/engine.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index 4ee92794941..9c604d1eb8c 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -3059,6 +3059,20 @@ exploded_graph::maybe_create_dynamic_call (const gcall *call, new_point.push_to_call_stack (sn_exit, next_point.get_supernode()); + + /* Impose a maximum recursion depth and don't analyze paths + that exceed it further. + This is something of a blunt workaround, but it only + applies to recursion (and mutual recursion), not to + general call stacks. */ + if (new_point.get_call_string ().calc_recursion_depth () + > param_analyzer_max_recursion_depth) + { + if (logger) + logger->log ("rejecting call edge: recursion limit exceeded"); + return false; + } + next_state.push_call (*this, node, call, uncertainty); if (next_state.m_valid)