mirror of https://github.com/llvm/circt.git
[FIRRTL][LowerClass] Pre-allocate namespaces before caputring refs (#7102)
There has been a lifetime bug that caused an UAF crash. Heaps allocated by DenseMap could be invalided when DenseMap size grows.
This commit is contained in:
parent
00edb48ed5
commit
ce012c04a1
|
@ -289,6 +289,13 @@ PathTracker::run(CircuitOp circuit, InstanceGraph &instanceGraph,
|
|||
const SymbolTable &symbolTable,
|
||||
const DenseMap<DistinctAttr, FModuleOp> &owningModules) {
|
||||
SmallVector<PathTracker> trackers;
|
||||
|
||||
// First allocate module namespaces. Don't capture a namespace reference at
|
||||
// this point since they could be invalidated when DenseMap grows.
|
||||
for (auto *node : instanceGraph)
|
||||
if (auto module = node->getModule<FModuleLike>())
|
||||
(void)namespaces.get(module);
|
||||
|
||||
// Prepare workers.
|
||||
for (auto *node : instanceGraph)
|
||||
if (auto module = node->getModule<FModuleLike>())
|
||||
|
|
Loading…
Reference in New Issue