https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/92345
>From 95336abaa000fa889888ce0f17af8098dfaeb8ea Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev <dvassil...@accesssoftek.com> Date: Thu, 16 May 2024 08:09:19 +0400 Subject: [PATCH 1/2] [lldb] Fixed an invalid error message in the DAP disconnect response The `disconnect` response contains the `error` message with invalid characters (a junk data). To reproduce this issue it is enough to run the TestDAP_commands test on Windows host and Linux target. The test will fail to run ELF file on Windows and dap_server will be disconnected unexpectedly. Note dap_server hangs if read_packet() cannot decode JSON with invalid characters. read_packet() must return None in this case instead of an exception. But dap_server does not require any fix after this patch. --- lldb/tools/lldb-dap/lldb-dap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp index 96da458be21d1..e9810f83678eb 100644 --- a/lldb/tools/lldb-dap/lldb-dap.cpp +++ b/lldb/tools/lldb-dap/lldb-dap.cpp @@ -977,7 +977,7 @@ void request_disconnect(const llvm::json::Object &request) { g_dap.debugger.SetAsync(false); lldb::SBError error = terminateDebuggee ? process.Kill() : process.Detach(); if (!error.Success()) - response.try_emplace("error", error.GetCString()); + response.try_emplace("error", std::string(error.GetCString())); g_dap.debugger.SetAsync(true); break; } >From 6528ad5c4e21f5cecaafb7a3b06285936e8dc1b3 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev <dvassil...@accesssoftek.com> Date: Thu, 16 May 2024 17:06:58 +0400 Subject: [PATCH 2/2] Replaced with EmplaceSafeString(). --- lldb/tools/lldb-dap/lldb-dap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp index e9810f83678eb..170fa88f1e8b8 100644 --- a/lldb/tools/lldb-dap/lldb-dap.cpp +++ b/lldb/tools/lldb-dap/lldb-dap.cpp @@ -977,7 +977,7 @@ void request_disconnect(const llvm::json::Object &request) { g_dap.debugger.SetAsync(false); lldb::SBError error = terminateDebuggee ? process.Kill() : process.Detach(); if (!error.Success()) - response.try_emplace("error", std::string(error.GetCString())); + EmplaceSafeString(response, "error", error.GetCString()); g_dap.debugger.SetAsync(true); break; } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits