[Lldb-commits] [lldb] 384d69f - [lldb] Cleanup dyld_process_t after constructing SharedCacheInfo (#106157)

via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 27 09:59:23 PDT 2024


Author: Alex Langford
Date: 2024-08-27T09:59:17-07:00
New Revision: 384d69fcbbd07941e7eb1899435e4d56d0469637

URL: https://github.com/llvm/llvm-project/commit/384d69fcbbd07941e7eb1899435e4d56d0469637
DIFF: https://github.com/llvm/llvm-project/commit/384d69fcbbd07941e7eb1899435e4d56d0469637.diff

LOG: [lldb] Cleanup dyld_process_t after constructing SharedCacheInfo (#106157)

Without calling `dyld_process_dispose`, LLDB will leak the memory
associated with the `dyld_process_t`.

rdar://134738265

Added: 
    

Modified: 
    lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 
    


################################################################################
diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index d27bd1b7426e6c..6e924fdc684cfe 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -650,12 +650,15 @@ static bool ResolveAndVerifyCandidateSupportDir(FileSpec &path) {
   if (!dyld_process)
     return false;
 
+  auto cleanup_process_on_exit =
+      llvm::make_scope_exit([&]() { dyld_process_dispose(dyld_process); });
+
   dyld_process_snapshot_t snapshot =
       dyld_process_snapshot_create_for_process(dyld_process, nullptr);
   if (!snapshot)
     return false;
 
-  auto on_exit =
+  auto cleanup_snapshot_on_exit =
       llvm::make_scope_exit([&]() { dyld_process_snapshot_dispose(snapshot); });
 
   dyld_shared_cache_t shared_cache =


        


More information about the lldb-commits mailing list