[PATCH] D69694: Memory leak fix for Managed Static Mutex

Alex Paige via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 17:54:00 PST 2019


paigeale updated this revision to Diff 228550.
paigeale added a comment.

Updated diff to keep original lock mechanism


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69694/new/

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());
+  {
+    std::lock_guard<std::recursive_mutex> Lock(*getManagedStaticMutex());
+
+    while (StaticList)
+      StaticList->destroy();
+  }
 
-  while (StaticList)
-    StaticList->destroy();
+  delete ManagedStaticMutex;
+  ManagedStaticMutex = nullptr;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69694.228550.patch
Type: text/x-patch
Size: 644 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191109/138129e6/attachment.bin>


More information about the llvm-commits mailing list