diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index a2144f15e..cd2e2246c 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -1107,7 +1107,13 @@ void AstNode::v3errorEndFatal(std::ostringstream& str) const { string AstNode::locationStr() const { string str = "... In instance "; const AstNode* backp = this; + int itmax = 10000; // Max iterations before giving up on location search while (backp) { + if (--itmax < 0) { + // Likely some circular back link, and V3Ast is trying to report a low-level error + UINFO(1, "Ran out of iterations finding locationStr on " << backp << endl); + return ""; + } const AstScope* scopep; if ((scopep = VN_CAST_CONST(backp, Scope))) { // The design is flattened and there are no useful scopes