Skip to content

Conversation

augusto2112
Copy link
Contributor

Now that the use after free bug has been fixed (397181d), actually use the new SharedModuleList class.

Now that the use after free bug has been fixed (397181d), actually use
the new SharedModuleList class.
@llvmbot
Copy link
Member

llvmbot commented Oct 8, 2025

@llvm/pr-subscribers-lldb

Author: Augusto Noronha (augusto2112)

Changes

Now that the use after free bug has been fixed (397181d), actually use the new SharedModuleList class.


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

1 Files Affected:

  • (modified) lldb/source/Core/ModuleList.cpp (+6-7)
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 2ccebf3fabfc5..c40612c1ced5e 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -989,7 +989,7 @@ class SharedModuleList {
 };
 
 struct SharedModuleListInfo {
-  ModuleList module_list;
+  SharedModuleList module_list;
   ModuleListProperties module_list_properties;
 };
 }
@@ -1007,7 +1007,7 @@ static SharedModuleListInfo &GetSharedModuleListInfo()
   return *g_shared_module_list_info;
 }
 
-static ModuleList &GetSharedModuleList() {
+static SharedModuleList &GetSharedModuleList() {
   return GetSharedModuleListInfo().module_list;
 }
 
@@ -1017,8 +1017,8 @@ ModuleListProperties &ModuleList::GetGlobalModuleListProperties() {
 
 bool ModuleList::ModuleIsInCache(const Module *module_ptr) {
   if (module_ptr) {
-    ModuleList &shared_module_list = GetSharedModuleList();
-    return shared_module_list.FindModule(module_ptr).get() != nullptr;
+    SharedModuleList &shared_module_list = GetSharedModuleList();
+    return shared_module_list.FindModule(*module_ptr).get() != nullptr;
   }
   return false;
 }
@@ -1041,9 +1041,8 @@ 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) {
-  ModuleList &shared_module_list = GetSharedModuleList();
-  std::lock_guard<std::recursive_mutex> guard(
-      shared_module_list.m_modules_mutex);
+  SharedModuleList &shared_module_list = GetSharedModuleList();
+  std::lock_guard<std::recursive_mutex> guard(shared_module_list.GetMutex());
   char path[PATH_MAX];
 
   Status error;

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but the "Add a null check" part doesn't look relevant anymore?

@augusto2112
Copy link
Contributor Author

LGTM but the "Add a null check" part doesn't look relevant anymore?

Yes I cherrypicked the original commit and forgot to change that part. I'll change the commit title on merge.

@augusto2112 augusto2112 merged commit 8523c6a into llvm:main Oct 9, 2025
11 checks passed
augusto2112 added a commit to augusto2112/llvm-project that referenced this pull request Oct 9, 2025
Now that the use after free bug has been fixed (397181d), actually use
the new SharedModuleList class.

(cherry picked from commit 8523c6a)
svkeerthy pushed a commit that referenced this pull request Oct 9, 2025
Now that the use after free bug has been fixed (397181d), actually use
the new SharedModuleList class.
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.

3 participants