[PATCH] D150184: [ORC] Fix race-condition in RTDyldObjectLinkingLayer::onObjEmit.
Lang Hames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 10 22:00:56 PDT 2023
lhames added a comment.
This is a really nice catch. Thank you for finding this!
I suspect the `ObjectLinkingLayer` has a similar issue. I'll look into that.
================
Comment at: llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp:366-391
+ // Add to MemMgrs before potentially notifying other threads, that the object
+ // was emitted. Otherwise these other threads could already execute the code
+ // and remove the object, leading to defunct resource trackers.
+ if (auto Err = R.withResourceKeyDo(
+ [&](ResourceKey K) { MemMgrs[K].push_back(std::move(MemMgr)); })) {
+ getExecutionSession().reportError(std::move(Err));
+ R.failMaterialization();
----------------
This call to `notifyObjectLoaded` will reference the moved-from `MemMgr` argument if there are any listeners attached.
The address of the MemMgr should be recorded in a local variable for use in the `notifyObjectLoaded` call. It would also be good if `MemMgr` were removed from the `MemMgrs` vector if the call to `notifyEmitted` fails.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150184/new/
https://reviews.llvm.org/D150184
More information about the llvm-commits
mailing list