Fix AddressSanitizer issues (#6406)

These are all genuine bugs, brief descriptions.

1. V3OrderCFuncEmitter.h used to delete a node early that was still
   reference in a graph dump later. Not a big deal, it can be deleted
   later at the end of V3Order.

2. V3Param.cpp: this one is tricky. The variable referenced by
   AstVarXRef was deleted at the end of `visit(AstGenCase*)`, but then
   `visit(AstVarXRef*)` checks `nodep->varp()` (already deleted) to see
   if it's in an interface.

3. V3String::wildMatch is sometimes called with an empty 's' (the string
   we are matching against tha pattern 'p'), in which case it used to go
   off into the woods. Added check on call. An arbitrary number of `*`
   will still match the empty string.

4. V3Task.cpp: There was an error reported for an unsupported construct,
   then a subsequent SEGV. Just signal the error upward so we bail on an
   error in a more graceful way.

5. verylog.y: Some unsupported constructs failed to set the parsed node,
   so some memory thrash made it into some code downstream. Just parse
   these into nullptr.

Also increased the timeout on one test, which sometimes tripped with
asan on GCC during heavy host load.
This commit is contained in:
Geza Lore
2025-09-09 13:55:00 +01:00
committed by GitHub
parent 0743d84bcc
commit 5ffa05fba0
9 changed files with 54 additions and 40 deletions
+6 -3
View File
@@ -976,7 +976,7 @@ class TaskVisitor final : public VNVisitor {
stmt += rtnvarp->basicp()->isDpiPrimitive() ? ";\n" : "[0];\n";
funcp->addStmtsp(new AstCStmt{nodep->fileline(), stmt});
}
makePortList(nodep, funcp);
if (!makePortList(nodep, funcp)) return nullptr;
return funcp;
}
@@ -1003,7 +1003,7 @@ class TaskVisitor final : public VNVisitor {
// Add DPI Import to top, since it's a global function
m_topScopep->scopep()->addBlocksp(funcp);
makePortList(nodep, funcp);
if (!makePortList(nodep, funcp)) return nullptr;
return funcp;
}
@@ -1047,7 +1047,8 @@ class TaskVisitor final : public VNVisitor {
}
}
static void makePortList(AstNodeFTask* nodep, AstCFunc* dpip) {
static bool makePortList(AstNodeFTask* nodep, AstCFunc* dpip) {
bool allOk = true;
// Copy nodep's list of function I/O to the new dpip c function
for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
if (AstVar* const portp = VN_CAST(stmtp, Var)) {
@@ -1057,6 +1058,7 @@ class TaskVisitor final : public VNVisitor {
newPortp->funcLocal(true);
dpip->addArgsp(newPortp);
if (!portp->basicp()) {
allOk = false;
portp->v3warn(
E_UNSUPPORTED,
"Unsupported: DPI argument of type "
@@ -1069,6 +1071,7 @@ class TaskVisitor final : public VNVisitor {
}
}
}
return allOk;
}
void bodyDpiImportFunc(AstNodeFTask* nodep, AstVarScope* rtnvscp, AstCFunc* cfuncp,