Fix debug infinite loop when bad coverage pointers

This commit is contained in:
Wilson Snyder 2024-02-07 19:57:02 -05:00
parent 07d86bf91d
commit 715dce546f
2 changed files with 10 additions and 2 deletions

View File

@ -2651,7 +2651,8 @@ public:
, m_offset{offset} {}
ASTGEN_MEMBERS_AstCoverDecl;
const char* broken() const override {
if (m_dataDeclp && m_dataDeclp->m_dataDeclp) { // Avoid O(n^2) accessing
if (m_dataDeclp
&& (m_dataDeclp == this || m_dataDeclp->m_dataDeclp)) { // Avoid O(n^2) accessing
v3fatalSrc("dataDeclp should point to real data, not be a list");
}
return nullptr;

View File

@ -2146,8 +2146,15 @@ void AstCoverDecl::dump(std::ostream& str) const {
if (!page().empty()) str << " page=" << page();
if (!linescov().empty()) str << " lc=" << linescov();
if (this->dataDeclNullp()) {
static bool s_recursing = false;
str << " -> ";
this->dataDeclNullp()->dump(str);
if (s_recursing) {
str << "%ErrorRECURSIVE";
} else {
s_recursing = true;
this->dataDeclNullp()->dump(str);
s_recursing = false;
}
} else {
if (binNum()) str << " bin" << std::dec << binNum();
}