[Lldb-commits] [lldb] [lldb] Fixed an invalid error message in the DAP disconnect response (PR #92345)
Dmitry Vasilyev via lldb-commits
lldb-commits at lists.llvm.org
Wed May 15 21:11:42 PDT 2024
https://github.com/slydiman created https://github.com/llvm/llvm-project/pull/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.
>From 95336abaa000fa889888ce0f17af8098dfaeb8ea Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev <dvassiliev at accesssoftek.com>
Date: Thu, 16 May 2024 08:09:19 +0400
Subject: [PATCH] [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;
}
More information about the lldb-commits
mailing list