mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
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:
+7
-14
@@ -41,14 +41,15 @@ std::map<string, string> VName::s_dehashMap;
|
||||
// Wildcard
|
||||
|
||||
// Double procedures, inlined, unrolls loop much better
|
||||
bool VString::wildmatchi(const char* s, const char* p) VL_PURE {
|
||||
template <bool Even = true>
|
||||
static bool wildMatchImpl(const char* s, const char* p) VL_PURE {
|
||||
for (; *p; s++, p++) {
|
||||
if (*p != '*') {
|
||||
if (((*s) != (*p)) && *p != '?') return false;
|
||||
} else {
|
||||
// Trailing star matches everything.
|
||||
if (!*++p) return true;
|
||||
while (!wildmatch(s, p)) {
|
||||
while (!wildMatchImpl<!Even>(s, p)) {
|
||||
if (*++s == '\0') return false;
|
||||
}
|
||||
return true;
|
||||
@@ -58,19 +59,11 @@ bool VString::wildmatchi(const char* s, const char* p) VL_PURE {
|
||||
}
|
||||
|
||||
bool VString::wildmatch(const char* s, const char* p) VL_PURE {
|
||||
for (; *p; s++, p++) {
|
||||
if (*p != '*') {
|
||||
if (((*s) != (*p)) && *p != '?') return false;
|
||||
} else {
|
||||
// Trailing star matches everything.
|
||||
if (!*++p) return true;
|
||||
while (!wildmatchi(s, p)) {
|
||||
if (*++s == '\0') return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (*s == '\0') {
|
||||
while (*p == '*') ++p;
|
||||
return *p == '\0';
|
||||
}
|
||||
return (*s == '\0');
|
||||
return wildMatchImpl(s, p);
|
||||
}
|
||||
|
||||
bool VString::wildmatch(const string& s, const string& p) VL_PURE {
|
||||
|
||||
Reference in New Issue
Block a user