From f579dcf816b5626724e9eae5feea594008b5c863 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilyev Date: Thu, 16 May 2024 18:34:22 +0400 Subject: [PATCH] [lldb] Fixed an invalid error message in the DAP disconnect response (#92345) 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 96da458be21d11..170fa88f1e8b84 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()); + EmplaceSafeString(response, "error", error.GetCString()); g_dap.debugger.SetAsync(true); break; }