public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Ankur saini <arsenic@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-3139] analyzer: Impose recursion limit on indirect calls.
Date: Wed, 25 Aug 2021 13:30:58 +0000 (GMT)	[thread overview]
Message-ID: <20210825133058.AF5353858432@sourceware.org> (raw)

https://gcc.gnu.org/g:43a5d46feabd93ba78983919234f05f5fc9a0982

commit r12-3139-g43a5d46feabd93ba78983919234f05f5fc9a0982
Author: Ankur Saini <arsenic@sourceware.org>
Date:   Wed Aug 25 12:33:06 2021 +0530

    analyzer: Impose recursion limit on indirect calls.
    
    2021-08-25  Ankur Saini  <arsenic@sourceware.org>
    
    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)


                 reply	other threads:[~2021-08-25 13:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210825133058.AF5353858432@sourceware.org \
    --to=arsenic@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).