From 1448068b6966587f3b1a39ac9e4bb3f97ad6fb08 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 25 Jul 2020 03:12:09 -0700 Subject: [PATCH] kern: fix assertion in KThread::(Try)Suspend --- libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp | 1 + libraries/libmesosphere/source/kern_k_thread.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp index e344e98c5..c43fea431 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_thread.hpp @@ -445,6 +445,7 @@ namespace ams::kern { constexpr u32 GetSuspendFlags() const { return this->suspend_allowed_flags & this->suspend_request_flags; } constexpr bool IsSuspended() const { return this->GetSuspendFlags() != 0; } constexpr bool IsSuspendRequested(SuspendType type) const { return (this->suspend_request_flags & (1u << (ThreadState_SuspendShift + type))) != 0; } + constexpr bool IsSuspendRequested() const { return this->suspend_request_flags != 0; } void RequestSuspend(SuspendType type); void Resume(SuspendType type); void TrySuspend(); diff --git a/libraries/libmesosphere/source/kern_k_thread.cpp b/libraries/libmesosphere/source/kern_k_thread.cpp index 6a050f2a1..8c3a465cc 100644 --- a/libraries/libmesosphere/source/kern_k_thread.cpp +++ b/libraries/libmesosphere/source/kern_k_thread.cpp @@ -576,7 +576,7 @@ namespace ams::kern { void KThread::TrySuspend() { MESOSPHERE_ASSERT_THIS(); MESOSPHERE_ASSERT(KScheduler::IsSchedulerLockedByCurrentThread()); - MESOSPHERE_ASSERT(this->IsSuspended()); + MESOSPHERE_ASSERT(this->IsSuspendRequested()); /* Ensure that we have no waiters. */ if (this->GetNumKernelWaiters() > 0) { @@ -591,7 +591,7 @@ namespace ams::kern { void KThread::Suspend() { MESOSPHERE_ASSERT_THIS(); MESOSPHERE_ASSERT(KScheduler::IsSchedulerLockedByCurrentThread()); - MESOSPHERE_ASSERT(this->IsSuspended()); + MESOSPHERE_ASSERT(this->IsSuspendRequested()); /* Set our suspend flags in state. */ const auto old_state = this->thread_state;