-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[MLIR][LLVM] Recursion importer handle repeated self-references #87295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
eeec239
63de5f0
2f234ca
2628aaf
da59f2f
b93e38d
aae2452
d1f227d
ab918dd
4dd4f71
5f17d05
12c8ef2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,18 +216,15 @@ DebugTranslation::translateImpl(DIGlobalVariableAttr attr) { | |
llvm::DIType * | ||
DebugTranslation::translateRecursive(DIRecursiveTypeAttrInterface attr) { | ||
DistinctAttr recursiveId = attr.getRecId(); | ||
if (attr.isRecSelf()) { | ||
auto *iter = recursiveTypeMap.find(recursiveId); | ||
assert(iter != recursiveTypeMap.end() && "unbound DI recursive self type"); | ||
if (auto *iter = recursiveTypeMap.find(recursiveId); | ||
iter != recursiveTypeMap.end()) { | ||
return iter->second; | ||
} else { | ||
assert(!attr.isRecSelf() && "unbound DI recursive self type"); | ||
} | ||
|
||
auto setRecursivePlaceholder = [&](llvm::DIType *placeholder) { | ||
[[maybe_unused]] auto [iter, inserted] = | ||
recursiveTypeMap.try_emplace(recursiveId, placeholder); | ||
(void)iter; | ||
(void)inserted; | ||
assert(inserted && "illegal reuse of recursive id"); | ||
recursiveTypeMap.try_emplace(recursiveId, placeholder); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We found some leak sanitizer issue with this locally :(. It looks like it can happen that the temporary remains in the IR somehow. My suspicion is that we need to overwrite the entry here now that we allow nested occurrences of the same recursive type? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. input.txt There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oof 🤦 thanks for the test case. I think the emplace here is guaranteed to insert because the check above will return if the recId is found in the map. I see that this use-after-free is the temporary that was created, and then RAUW'ed, but referenced again. I'm afraid we might have just exposed an existing issue with the exporter? Let me take a closer look 👀 ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if my testing is correct, this fixes the memory leak: #88122. Apparently we were just caching temporary nodes, causing them to be reused after RAUW. |
||
}; | ||
|
||
llvm::DIType *result = | ||
|
Uh oh!
There was an error while loading. Please reload this page.