From eea36e8a375f1ecd9c7171b160f74c9f675a9bb9 Mon Sep 17 00:00:00 2001 From: svc64 Date: Sat, 16 Dec 2023 20:03:25 +0200 Subject: [PATCH] Fix debugger crash when using "info thread" --- src/Ryujinx.HLE/Debugger/Debugger.cs | 8 +++++++- src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Ryujinx.HLE/Debugger/Debugger.cs b/src/Ryujinx.HLE/Debugger/Debugger.cs index d7521b17b7..e9f535440b 100644 --- a/src/Ryujinx.HLE/Debugger/Debugger.cs +++ b/src/Ryujinx.HLE/Debugger/Debugger.cs @@ -554,11 +554,17 @@ namespace Ryujinx.HLE.Debugger void CommandSetThread(char op, ulong? threadId) { - if (threadId == 0) + if (threadId == 0 || threadId == null) { threadId = GetThreads().First().ThreadUid; } + if (DebugProcess.GetThread(threadId.Value) == null) + { + ReplyError(); + return; + } + switch (op) { case 'c': diff --git a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs index 0dd280489e..abd792cc56 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs @@ -1306,7 +1306,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process { lock (_parent._threadingLock) { - return _parent._threads.Select(x => x.ThreadUid).ToArray(); + var threads = _parent._threads.Where(x => !x.TerminationRequested).ToArray(); + return threads.Select(x => x.ThreadUid).ToArray(); } } @@ -1314,7 +1315,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process { lock (_parent._threadingLock) { - return _parent._threads.FirstOrDefault(x => x.ThreadUid == threadUid); + var threads = _parent._threads.Where(x => !x.TerminationRequested).ToArray(); + return threads.FirstOrDefault(x => x.ThreadUid == threadUid); } }