public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] analyzer: Impose recursion limit on indirect calls.
@ 2021-08-25  8:09 Ankur Saini
  2021-08-25 13:22 ` David Malcolm
  0 siblings, 1 reply; 9+ messages in thread
From: Ankur Saini @ 2021-08-25  8:09 UTC (permalink / raw)
  To: gcc Patches

[-- Attachment #1: Type: text/plain, Size: 178 bytes --]

This should also fix the failing regression found in PR analyzer/101980.

- The patch is in sync with current master
- successfully bootstrapped and tested on x86_64-linux-gnu.


[-- Attachment #2: fix.patch --]
[-- Type: application/octet-stream, Size: 1533 bytes --]

From 8e6c04e508d88184780af10f5027b92ce4caa5ae Mon Sep 17 00:00:00 2001
From: Ankur Saini <arsenic@sourceware.org>
Date: Wed, 25 Aug 2021 12:33:06 +0530
Subject: [PATCH] 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.
---
 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)
-- 
2.32.0


[-- Attachment #3: Type: text/plain, Size: 17 bytes --]



Thanks 
- Ankur

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-09-20 12:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25  8:09 [PATCH] analyzer: Impose recursion limit on indirect calls Ankur Saini
2021-08-25 13:22 ` David Malcolm
2021-08-25 13:54   ` Martin Liška
     [not found]     ` <9C51062C-3457-4345-9BDC-20F7FE4BFA1E@gmail.com>
2021-08-25 15:05       ` David Malcolm
2021-08-25 15:55         ` Ankur Saini
2021-08-25 17:15           ` David Malcolm
2021-08-27 12:44             ` Ankur Saini
2021-08-27 12:58               ` Martin Liška
2021-09-20 12:36                 ` Ankur Saini

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).