[Lldb-commits] [lldb] [lldb] Fix crash on creating string error (PR #212503)

Ebuka Ezike via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 28 07:05:31 PDT 2026


https://github.com/da-viper created https://github.com/llvm/llvm-project/pull/212503

It crashes because the `default` error string may not be a format string compared to the `fallback` error string

>From 40d9750cfb88e97526925b7394e2baa2b92f578c Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Tue, 28 Jul 2026 14:59:55 +0100
Subject: [PATCH] [lldb] Fix crash on creating string error

It crashes because the `default` error string may not be a format string
compared to the `fallback` error string
---
 lldb/source/Target/Target.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 148d7e0b30dbb..bb0c02e0f7930 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -3119,11 +3119,13 @@ Target::ReadInstructions(const Address &start_addr, uint32_t count,
       ReadMemory(start_addr, data.GetBytes(), data.GetByteSize(), error,
                  force_live_memory, &load_addr);
 
-  if (error.Fail())
+  if (error.Fail()) {
+    if (error.AsCString(/*default_error_str=*/nullptr))
+      return error.takeError();
     return llvm::createStringErrorV(
-        error.AsCString(
-            "Target::ReadInstructions failed to read memory at {:x}"),
+        "Target::ReadInstructions failed to read memory at {:x}",
         start_addr.GetLoadAddress(this));
+  }
 
   const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
   if (!flavor_string || flavor_string[0] == '\0') {



More information about the lldb-commits mailing list