[Lldb-commits] [lldb] [lldb] Oversized DW_OP_piece triggers an unbounded allocation and aborts LLDB (PR #209397)
Alexsander Borges Damaceno via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 14 01:18:03 PDT 2026
https://github.com/AlexsanderDamaceno updated https://github.com/llvm/llvm-project/pull/209397
>From 4596168d38ca0c7c39a7fc97c68dd54d6cfb44ca Mon Sep 17 00:00:00 2001
From: AlexsanderDamaceno <aemgbo at gmail.com>
Date: Tue, 14 Jul 2026 05:16:18 -0300
Subject: [PATCH] E
---
lldb/source/Expression/DWARFExpression.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index c4c86b408accd..12ae9d4ecdcd1 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1107,6 +1107,15 @@ static llvm::Error Evaluate_DW_OP_piece(EvalContext &eval_ctx,
if (piece_byte_size == 0)
return llvm::Error::success();
+ // A single piece of a variable's location can never legitimately be
+ // this large.
+ constexpr uint64_t kMaxDWARFPieceByteSize = 1024 * 1024 * 1024; // 1GB
+ if (piece_byte_size > kMaxDWARFPieceByteSize)
+ return llvm::createStringError(
+ "DW_OP_piece(%" PRIu64 ") is larger than the maximum allowed "
+ "size of %" PRIu64 " bytes",
+ piece_byte_size, kMaxDWARFPieceByteSize);
+
Value curr_piece;
if (eval_ctx.stack.empty()) {
More information about the lldb-commits
mailing list