[llvm] r343286 - [ORC] Lock ThreadSafeContext during module destruction in ThreadSafeModule's
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 27 18:41:29 PDT 2018
Author: lhames
Date: Thu Sep 27 18:41:29 2018
New Revision: 343286
URL: http://llvm.org/viewvc/llvm-project?rev=343286&view=rev
Log:
[ORC] Lock ThreadSafeContext during module destruction in ThreadSafeModule's
move constructor.
This is basically the same fix as r343261, but applied to the move constructor:
Failure to lock the context during module destruction can lead to data races if
other threads are operating on the context.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h?rev=343286&r1=343285&r2=343286&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/ThreadSafeModule.h Thu Sep 27 18:41:29 2018
@@ -93,6 +93,12 @@ public:
// reverse order (i.e. module first) to ensure the dependencies are
// protected: The old module that is being overwritten must be destroyed
// *before* the context that it depends on.
+ // We also need to lock the context to make sure the module tear-down
+ // does not overlap any other work on the context.
+ if (M) {
+ auto L = getContextLock();
+ M = nullptr;
+ }
M = std::move(Other.M);
TSCtx = std::move(Other.TSCtx);
return *this;
More information about the llvm-commits
mailing list