Skip to content

Conversation

@augusto2112
Copy link
Contributor

…st class"

This reverts commit 234e075.

I'm reverting this because the ASAN build fails running the TestMiniDumpUUID.py test. This happens because the pointer is already freed before the call to RemoveIfOrpahaned. The ModuleList implementation never actually dereferences the pointer, so it worked correctly, but the new map implementation does dereference it, hence the crash.

@llvmbot
Copy link
Member

llvmbot commented Aug 26, 2025

@llvm/pr-subscribers-lldb

Author: Augusto Noronha (augusto2112)

Changes

…st class"

This reverts commit 234e075.

I'm reverting this because the ASAN build fails running the TestMiniDumpUUID.py test. This happens because the pointer is already freed before the call to RemoveIfOrpahaned. The ModuleList implementation never actually dereferences the pointer, so it worked correctly, but the new map implementation does dereference it, hence the crash.


Full diff: https://github.com/llvm/llvm-project/pull/155327.diff

1 Files Affected:

  • (modified) lldb/source/Core/ModuleList.cpp (+7-8)
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 060732f421f88..bc63a41c90d17 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -844,8 +844,6 @@ class SharedModuleList {
   }
 
   bool RemoveIfOrphaned(const Module *module_ptr) {
-    if (!module_ptr)
-      return false;
     std::lock_guard<std::recursive_mutex> guard(GetMutex());
     RemoveFromMap(*module_ptr, /*if_orphaned=*/true);
     return m_list.RemoveIfOrphaned(module_ptr);
@@ -982,7 +980,7 @@ class SharedModuleList {
 };
 
 struct SharedModuleListInfo {
-  SharedModuleList module_list;
+  ModuleList module_list;
   ModuleListProperties module_list_properties;
 };
 }
@@ -1000,7 +998,7 @@ static SharedModuleListInfo &GetSharedModuleListInfo()
   return *g_shared_module_list_info;
 }
 
-static SharedModuleList &GetSharedModuleList() {
+static ModuleList &GetSharedModuleList() {
   return GetSharedModuleListInfo().module_list;
 }
 
@@ -1010,8 +1008,8 @@ ModuleListProperties &ModuleList::GetGlobalModuleListProperties() {
 
 bool ModuleList::ModuleIsInCache(const Module *module_ptr) {
   if (module_ptr) {
-    SharedModuleList &shared_module_list = GetSharedModuleList();
-    return shared_module_list.FindModule(*module_ptr).get() != nullptr;
+    ModuleList &shared_module_list = GetSharedModuleList();
+    return shared_module_list.FindModule(module_ptr).get() != nullptr;
   }
   return false;
 }
@@ -1034,8 +1032,9 @@ ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
                             const FileSpecList *module_search_paths_ptr,
                             llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules,
                             bool *did_create_ptr, bool always_create) {
-  SharedModuleList &shared_module_list = GetSharedModuleList();
-  std::lock_guard<std::recursive_mutex> guard(shared_module_list.GetMutex());
+  ModuleList &shared_module_list = GetSharedModuleList();
+  std::lock_guard<std::recursive_mutex> guard(
+      shared_module_list.m_modules_mutex);
   char path[PATH_MAX];
 
   Status error;

@augusto2112 augusto2112 merged commit 3c91d58 into llvm:main Aug 26, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants