[Lldb-commits] [lldb] [LLDB] Fix crash after second run when set a previous watchpoint. (PR #136649)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Apr 21 20:44:35 PDT 2025
https://github.com/hapeeeeee created https://github.com/llvm/llvm-project/pull/136649
This PR fixes a crash in `LLDB` caused by a dangling pointer to a reused `ValueObjectSP` when re-running the debuggee and setting the same watchpoint again.
As described by @jasonmolenda, the fix is to reinitialize the dangling pointer in `Watchpoint::SetEnabled`.
This PR closes [#135590](https://github.com/llvm/llvm-project/issues/135590).
>From a1de5a864df3ac33815d5b6eb20f104a773d28c1 Mon Sep 17 00:00:00 2001
From: hapeeeeee <623151737 at qq.com>
Date: Tue, 22 Apr 2025 11:34:38 +0800
Subject: [PATCH] [lldb] Fix crash after second run when set a previous
watchpoint.
---
lldb/source/Breakpoint/Watchpoint.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/lldb/source/Breakpoint/Watchpoint.cpp b/lldb/source/Breakpoint/Watchpoint.cpp
index 2df848aaa0576..b4bde7afab223 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -409,6 +409,15 @@ bool Watchpoint::IsDisabledDuringEphemeralMode() {
}
void Watchpoint::SetEnabled(bool enabled, bool notify) {
+ // Whenever setting the enabled state of a watchpoint, we need to ensure
+ // that `m_new_value_sp` exists to avoid crash when reading old_data later.
+ // See https://github.com/llvm/llvm-project/issues/135590.
+ if (!m_new_value_sp) {
+ ExecutionContext exe_ctx;
+ m_target.GetProcessSP()->CalculateExecutionContext(exe_ctx);
+ CaptureWatchedValue(exe_ctx);
+ }
+
if (!enabled) {
if (m_is_ephemeral)
++m_disabled_count;
More information about the lldb-commits
mailing list