ted created this revision. ted added a reviewer: clayborg. ted requested review of this revision. Herald added a project: LLDB.
If the remote gdbserver's qfThreadInfo reply has a trailing comma, GDBRemoteCommunicationClient::GetCurrentProcessAndThreadIDs will return an empty vector of thread ids. This will cause lldb to recurse through three functions trying to get the list of threads, until it blows its stack and crashes. A trailing comma is a malformed response, but it shouldn't cause lldb to crash. This patch will return the tids received before the malformed response. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D109937 Files: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp =================================================================== --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -2906,8 +2906,13 @@ if (ch == 'm') { do { auto pid_tid = response.GetPidTid(LLDB_INVALID_PROCESS_ID); - if (!pid_tid) - return {}; + if (!pid_tid) { + // if ids is empty, this is an error + if (ids.size() == 0) + return {}; + // if ids is not empty, bail out from here and process ids + break; + } ids.push_back(pid_tid.getValue()); ch = response.GetChar(); // Skip the command separator
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp =================================================================== --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -2906,8 +2906,13 @@ if (ch == 'm') { do { auto pid_tid = response.GetPidTid(LLDB_INVALID_PROCESS_ID); - if (!pid_tid) - return {}; + if (!pid_tid) { + // if ids is empty, this is an error + if (ids.size() == 0) + return {}; + // if ids is not empty, bail out from here and process ids + break; + } ids.push_back(pid_tid.getValue()); ch = response.GetChar(); // Skip the command separator
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits