-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][HeuristicResolver] Additional hardening against an infinite loop in simplifyType() #126690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang][HeuristicResolver] Additional hardening against an infinite loop in simplifyType() #126690
Conversation
…oop in simplifyType()
@llvm/pr-subscribers-clang Author: Nathan Ridge (HighCommander4) ChangesFull diff: https://github.com/llvm/llvm-project/pull/126690.diff 1 Files Affected:
diff --git a/clang/lib/Sema/HeuristicResolver.cpp b/clang/lib/Sema/HeuristicResolver.cpp
index 3cbf33dcdced38..adce403412f689 100644
--- a/clang/lib/Sema/HeuristicResolver.cpp
+++ b/clang/lib/Sema/HeuristicResolver.cpp
@@ -258,7 +258,11 @@ QualType HeuristicResolverImpl::simplifyType(QualType Type, const Expr *E,
}
return T;
};
- while (!Current.Type.isNull()) {
+ // As an additional protection against infinite loops, bound the number of
+ // simplification steps.
+ size_t StepCount = 0;
+ const size_t MaxSteps = 64;
+ while (!Current.Type.isNull() && StepCount++ < MaxSteps) {
TypeExprPair New = SimplifyOneStep(Current);
if (New.Type == Current.Type)
break;
|
This is not needed to fix #126536 (#126689 does that), it's a hedge against additional bugs that may be lurking that cause infinite loops. I'm open to suggestions as to whether this is a good idea. It may hide some bugs, but the symptoms of those bugs are much less severe (incorrect or failed heuristic resolution of a dependent name in a template) than an infinite loop. |
what about landing this one, and cherry picking it into the 20 release. then we can land #126689 and revert this one. giving us the next release cycle to vet the underlying change? |
going to land this one, since review of #126689 can take longer and this should enable us to unblock our releases. I am happy to revert afterwards. |
7808946
into
users/HighCommander4/issue-126536
oops I wasn't looking at the target branch :( let me cherry-pick this into main |
The regressing change, which introduced the |
…oop in simplifyType() (#126690)
…oop in simplifyType() (llvm#126690)
…oop in simplifyType() (llvm#126690)
…oop in simplifyType() (llvm#126690)
No description provided.