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. Reviewed By: clayborg, labath Differential Revision: https://reviews.llvm.org/D109937
28 lines
988 B
Python
28 lines
988 B
Python
import lldb
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test.decorators import *
|
|
from gdbclientutils import *
|
|
|
|
|
|
class TestThreadInfoTrailingComma(GDBRemoteTestBase):
|
|
|
|
def test(self):
|
|
class MyResponder(MockGDBServerResponder):
|
|
def haltReason(self):
|
|
return "T02thread:1"
|
|
|
|
def qfThreadInfo(self):
|
|
return "m1,2,3,4,"
|
|
|
|
self.server.responder = MyResponder()
|
|
target = self.dbg.CreateTarget('')
|
|
if self.TraceOn():
|
|
self.runCmd("log enable gdb-remote packets")
|
|
self.addTearDownHook(
|
|
lambda: self.runCmd("log disable gdb-remote packets"))
|
|
process = self.connect(target)
|
|
self.assertEqual(process.GetThreadAtIndex(0).GetThreadID(), 1)
|
|
self.assertEqual(process.GetThreadAtIndex(1).GetThreadID(), 2)
|
|
self.assertEqual(process.GetThreadAtIndex(2).GetThreadID(), 3)
|
|
self.assertEqual(process.GetThreadAtIndex(3).GetThreadID(), 4)
|