Skip to content

[NFC][lldb]Fix stack-use-after-free bugs in exit-callbacks. #135763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025

Conversation

oontvoo
Copy link
Member

@oontvoo oontvoo commented Apr 15, 2025

No description provided.

@oontvoo oontvoo requested a review from JDevlieghere as a code owner April 15, 2025 08:50
@llvmbot llvmbot added the lldb label Apr 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 15, 2025

@llvm/pr-subscribers-lldb

Author: Vy Nguyen (oontvoo)

Changes

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

2 Files Affected:

  • (modified) lldb/source/Target/Process.cpp (+5-4)
  • (modified) lldb/source/Target/Target.cpp (+1-1)
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 633f7488dc76a..73557eb767c72 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1047,10 +1047,11 @@ bool Process::SetExitStatus(int status, llvm::StringRef exit_string) {
     info->exit_desc = {status, exit_string.str()};
   });
 
-  helper.DispatchOnExit([&](telemetry::ProcessExitInfo *info) {
-    info->module_uuid = module_uuid;
-    info->pid = m_pid;
-  });
+  helper.DispatchOnExit(
+      [module_uuid, pid = m_pid](telemetry::ProcessExitInfo *info) {
+        info->module_uuid = module_uuid;
+        info->pid = pid;
+      });
 
   m_exit_status = status;
   if (!exit_string.empty())
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 42b1561fb2993..b6186b76d6236 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1578,7 +1578,7 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
       info->is_start_entry = true;
     });
 
-    helper.DispatchOnExit([&](telemetry::ExecutableModuleInfo *info) {
+    helper.DispatchOnExit([&, pid](telemetry::ExecutableModuleInfo *info) {
       info->exec_mod = executable_sp;
       info->uuid = executable_sp->GetUUID();
       info->pid = pid;

@oontvoo oontvoo merged commit 81499ed into llvm:main Apr 15, 2025
6 of 10 checks passed
var-const pushed a commit to ldionne/llvm-project that referenced this pull request Apr 17, 2025
@oontvoo oontvoo deleted the stack_bug branch June 2, 2025 17:17
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