[PATCH] D69694: Memory leak fix for Managed Static Mutex
Alex Paige via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 31 17:12:50 PDT 2019
paigeale created this revision.
paigeale added a reviewer: hliao.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
When llvm exists inside of a dll and one links to the LLVM libraries there exists a memory leak on the unload of the dll because the mutex inside of the ManagedStatic class does not get released.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69694
Files:
llvm/lib/Support/ManagedStatic.cpp
Index: llvm/lib/Support/ManagedStatic.cpp
===================================================================
--- llvm/lib/Support/ManagedStatic.cpp
+++ llvm/lib/Support/ManagedStatic.cpp
@@ -76,8 +76,13 @@
/// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
void llvm::llvm_shutdown() {
- std::lock_guard<std::recursive_mutex> Lock(*getManagedStaticMutex());
+ getManagedStaticMutex()->lock();
while (StaticList)
StaticList->destroy();
+
+ getManagedStaticMutex()->unlock();
+
+ delete ManagedStaticMutex;
+ ManagedStaticMutex = nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69694.227381.patch
Type: text/x-patch
Size: 581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191101/2c6c6017/attachment.bin>
More information about the llvm-commits
mailing list