Skip to content

Commit eff27f3

Browse files
authored
Kernel: Store previous thread state upon all transitions to Stopped (#1753)
We now store the previous thread state in m_stop_state for all transitions to the Stopped state via Thread::set_state. Fixes #1752 whereupon resuming a thread that was stopped with SIGTSTP, the previous state of the thread is not remembered correctly, resulting in m_stop_state == State::Invalid and the associated assertion fails.
1 parent 8aab8fa commit eff27f3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Kernel/Thread.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
499499
if (signal == SIGSTOP) {
500500
if (!is_stopped()) {
501501
m_stop_signal = SIGSTOP;
502-
m_stop_state = m_state;
503502
set_state(State::Stopped);
504503
}
505504
return ShouldUnblockThread::No;
@@ -526,7 +525,6 @@ ShouldUnblockThread Thread::dispatch_signal(u8 signal)
526525
// make sure SemiPermanentBlocker is unblocked
527526
if (m_blocker && m_blocker->is_reason_signal())
528527
unblock();
529-
m_stop_state = m_state;
530528
set_state(Stopped);
531529
return ShouldUnblockThread::No;
532530
}
@@ -757,6 +755,10 @@ void Thread::set_state(State new_state)
757755
ASSERT(m_blocker != nullptr);
758756
}
759757

758+
if (new_state == Stopped) {
759+
m_stop_state = m_state;
760+
}
761+
760762
m_state = new_state;
761763
if (m_process.pid() != 0) {
762764
Scheduler::update_state_for_thread(*this);

0 commit comments

Comments
 (0)