[Lldb-commits] [lldb] f579dcf - [lldb] Fixed an invalid error message in the DAP disconnect response (#92345)

via lldb-commits lldb-commits at lists.llvm.org
Thu May 16 07:34:27 PDT 2024


Author: Dmitry Vasilyev
Date: 2024-05-16T18:34:22+04:00
New Revision: f579dcf816b5626724e9eae5feea594008b5c863

URL: https://github.com/llvm/llvm-project/commit/f579dcf816b5626724e9eae5feea594008b5c863
DIFF: https://github.com/llvm/llvm-project/commit/f579dcf816b5626724e9eae5feea594008b5c863.diff

LOG: [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.

Added: 
    

Modified: 
    lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index 96da458be21d1..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", error.GetCString());
+      EmplaceSafeString(response, "error", error.GetCString());
     g_dap.debugger.SetAsync(true);
     break;
   }


        


More information about the lldb-commits mailing list