public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] Add a recursion-limit when resolving Parameter Types
Date: Wed,  8 Jun 2022 11:47:51 +0000 (GMT)	[thread overview]
Message-ID: <20220608114751.272703985474@sourceware.org> (raw)

https://gcc.gnu.org/g:c6dc53f9e2e95295936c970019c8cbd573a8e4f6

commit c6dc53f9e2e95295936c970019c8cbd573a8e4f6
Author: Philip Herron <philip.herron@embecosm.com>
Date:   Wed Nov 3 14:37:52 2021 +0000

    Add a recursion-limit when resolving Parameter Types
    
    This limit is likely way too low but its ok for now to get decent
    backtraces for the test-cases we are working with right now.

Diff:
---
 gcc/rust/backend/rust-compile-context.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h
index 551e0413007..396cb10c263 100644
--- a/gcc/rust/backend/rust-compile-context.h
+++ b/gcc/rust/backend/rust-compile-context.h
@@ -367,6 +367,9 @@ public:
 
   void visit (const TyTy::ParamType &param) override
   {
+    recursion_count++;
+    rust_assert (recursion_count < kDefaultRecusionLimit);
+
     param.resolve ()->accept_vis (*this);
   }
 
@@ -670,12 +673,16 @@ public:
 
 private:
   TyTyResolveCompile (Context *ctx, bool trait_object_mode)
-    : ctx (ctx), trait_object_mode (trait_object_mode), translated (nullptr)
+    : ctx (ctx), trait_object_mode (trait_object_mode), translated (nullptr),
+      recursion_count (0)
   {}
 
   Context *ctx;
   bool trait_object_mode;
   ::Btype *translated;
+  size_t recursion_count;
+
+  static const size_t kDefaultRecusionLimit = 5;
 };
 
 } // namespace Compile


                 reply	other threads:[~2022-06-08 11:47 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=20220608114751.272703985474@sourceware.org \
    --to=tschwinge@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).