public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Add a recursion-limit when resolving Parameter Types
@ 2022-06-08 11:47 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 11:47 UTC (permalink / raw)
To: gcc-cvs
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 ¶m) 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 11:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 11:47 [gcc/devel/rust/master] Add a recursion-limit when resolving Parameter Types Thomas Schwinge
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).