[Lldb-commits] [lldb] [lldb] Fix possible invalidated iterator. (PR #198482)
Ebuka Ezike via lldb-commits
lldb-commits at lists.llvm.org
Tue May 19 03:08:42 PDT 2026
https://github.com/da-viper created https://github.com/llvm/llvm-project/pull/198482
The begin or end interator may be invalidated when a idx_pos in erased from the vector.
Unblocks sanitised CI.
>From 52ee2af582094e39a2cd5f1b59d0bb02f057f3b6 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <e_ezike at apple.com>
Date: Tue, 19 May 2026 11:05:09 +0100
Subject: [PATCH] [lldb] Fix possible invalidated iterator.
The begin or end interator may be invalidated when an
idx_pos in erased from the vector
---
lldb/source/Target/Target.cpp | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index d6bf25630fa65..e2523c4d9206b 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -72,6 +72,7 @@
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/ErrorExtras.h"
@@ -977,20 +978,18 @@ void Target::DescribeBreakpointOverrides(Stream &stream,
return;
}
- auto begin = idxs.begin();
- auto end = idxs.end();
- bool empty = idxs.empty();
+ const bool empty = idxs.empty();
bool print_first = true;
- for (auto const &elem : m_breakpoint_overrides) {
- auto idx_pos = empty ? end : std::find(begin, end, elem.first);
- if (empty || idx_pos != end) {
+ for (const auto &[id, resolver] : m_breakpoint_overrides) {
+ auto idx_pos = llvm::find(idxs, id);
+ if (empty || idx_pos != idxs.end()) {
if (print_first) {
// FIXME: Is there some good way to flow the description?
stream << "ID Description\n";
stream << "---- -----------\n";
print_first = false;
}
- stream.Format("{0,4} {1}\n", elem.first, elem.second->GetDescription());
+ stream.Format("{0,4} {1}\n", id, resolver->GetDescription());
if (!empty)
idxs.erase(idx_pos);
}
More information about the lldb-commits
mailing list