[Lldb-commits] [lldb] [lldb] Cleanup dyld_process_t after constructing SharedCacheInfo (PR #106157)
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 26 16:17:11 PDT 2024
https://github.com/bulbazord created https://github.com/llvm/llvm-project/pull/106157
Without calling `dyld_process_dispose`, LLDB will leak the memory associated with the `dyld_process_t`.
rdar://134738265
>From 62bd1e90ea84cfb7bd6d18529918be544d036221 Mon Sep 17 00:00:00 2001
From: Alex Langford <alangford at apple.com>
Date: Mon, 26 Aug 2024 16:13:59 -0700
Subject: [PATCH] [lldb] Cleanup dyld_process_t after constructing
SharedCacheInfo
Without calling `dyld_process_dispose`, LLDB will leak the memory
associated with the `dyld_process_t`.
rdar://134738265
---
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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