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); } }