https://github.com/aahrun created https://github.com/llvm/llvm-project/pull/169844
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. >From 28aa746d16753483df75f0208651420a9a5f29c1 Mon Sep 17 00:00:00 2001 From: aaron <[email protected]> Date: Thu, 27 Nov 2025 17:25:48 +0000 Subject: [PATCH] [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); } _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
