https://github.com/c-rhodes updated 
https://github.com/llvm/llvm-project/pull/176224

>From c99041192208a59fa71ea39f5e7dcb8e1cecc08c Mon Sep 17 00:00:00 2001
From: Nerixyz <[email protected]>
Date: Wed, 14 Jan 2026 19:11:34 +0100
Subject: [PATCH] [LLDB] Prevent division by zero in MSVC deque formatter
 (#175842)

To look up an item in a `std::deque` we do
https://github.com/llvm/llvm-project/blob/d69335bac9d218ed5dadeebed66b600347d5db8e/lldb/source/Plugins/Language/CPlusPlus/MsvcStlDeque.cpp#L71-L73

This will crash on if `m_block_size` or `m_map_size` is zero. We didn't
check that these aren't zero. With this PR, we do.

When running the MSVC STL smoke test, `m_map_size` was randomly zero
(the test breaks before the variables are initialized) and the test
failed, because LLDB crashed.

(cherry picked from commit dddd2b706eb54cd70b3ac59adc6fb92343e9e101)
---
 lldb/source/Plugins/Language/CPlusPlus/MsvcStlDeque.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlDeque.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlDeque.cpp
index 7fd1e6691a4bd..de103e9e4a460 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MsvcStlDeque.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MsvcStlDeque.cpp
@@ -110,7 +110,7 @@ 
lldb_private::formatters::MsvcStlDequeSyntheticFrontEnd::Update() {
   if (!block_size_decl)
     return lldb::eRefetch;
   Scalar block_size = block_size_decl.GetConstantValue();
-  if (!block_size.IsValid())
+  if (!block_size.IsValid() || block_size <= 0)
     return lldb::eRefetch;
 
   ValueObjectSP offset_sp = storage_sp->GetChildMemberWithName("_Myoff");
@@ -126,7 +126,7 @@ 
lldb_private::formatters::MsvcStlDequeSyntheticFrontEnd::Update() {
     return lldb::eRefetch;
 
   uint64_t map_size = map_size_sp->GetValueAsUnsigned(0, &ok);
-  if (!ok)
+  if (!ok || map_size == 0)
     return lldb::eRefetch;
 
   uint64_t size = size_sp->GetValueAsUnsigned(0, &ok);

_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to