https://github.com/aahrun updated 
https://github.com/llvm/llvm-project/pull/169844

>From 28aa746d16753483df75f0208651420a9a5f29c1 Mon Sep 17 00:00:00 2001
From: aaron <[email protected]>
Date: Thu, 27 Nov 2025 17:25:48 +0000
Subject: [PATCH 1/2] [lldb-dap] Fix segfault in JSONUtils.cpp when
 GetUUIDString() returns nullptr

When creating a stack frame in JSONUtils.cpp CreateStackFrame() the code
constructs a std::string from module.GetUUIDString(), which can return
nullptr in some cases (as documented in the implementation of
SBModule::GetUUIDString()). This causes a segmentation fault when passed to
the std::string constructor.

This fix adds a null check before constructing the UUID string, falling back
to an empty string if nullptr is returned. The existing empty check ensures
the moduleId field is omitted from the JSON when no UUID exists.
---
 lldb/tools/lldb-dap/JSONUtils.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index 81eadae03bb48..1cc01cd547582 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -554,7 +554,8 @@ llvm::json::Value CreateStackFrame(DAP &dap, lldb::SBFrame 
&frame,
 
   lldb::SBModule module = frame.GetModule();
   if (module.IsValid()) {
-    std::string uuid = module.GetUUIDString();
+    const char *uuid_cstr = module.GetUUIDString();
+    std::string uuid = uuid_cstr ? uuid_cstr : "";
     if (!uuid.empty())
       object.try_emplace("moduleId", uuid);
   }

>From 679089ebe70fd2ba35789ffd98270beb57cddf0b Mon Sep 17 00:00:00 2001
From: Aaron <[email protected]>
Date: Fri, 28 Nov 2025 14:51:46 +0000
Subject: [PATCH 2/2] Update lldb/tools/lldb-dap/JSONUtils.cpp

Co-authored-by: Ebuka Ezike <[email protected]>
---
 lldb/tools/lldb-dap/JSONUtils.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp 
b/lldb/tools/lldb-dap/JSONUtils.cpp
index 1cc01cd547582..33f266b55bd2e 100644
--- a/lldb/tools/lldb-dap/JSONUtils.cpp
+++ b/lldb/tools/lldb-dap/JSONUtils.cpp
@@ -554,10 +554,8 @@ llvm::json::Value CreateStackFrame(DAP &dap, lldb::SBFrame 
&frame,
 
   lldb::SBModule module = frame.GetModule();
   if (module.IsValid()) {
-    const char *uuid_cstr = module.GetUUIDString();
-    std::string uuid = uuid_cstr ? uuid_cstr : "";
-    if (!uuid.empty())
-      object.try_emplace("moduleId", uuid);
+    if (const llvm::StringRef uuid = module.GetUUIDString(); !uuid.empty())
+      object.try_emplace("moduleId", uuid.str());
   }
 
   return llvm::json::Value(std::move(object));

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

Reply via email to