mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-22 23:55:12 +00:00
Kernel: Fix a few Thread::block related races
We need to have a Thread lock to protect threading related operations, such as Thread::m_blocker which is used in Thread::block. Also, if a Thread::Blocker indicates that it should be unblocking immediately, don't actually block the Thread and instead return immediately in Thread::block.
This commit is contained in:
@@ -63,8 +63,11 @@ KResultOr<u32> handle_syscall(const Kernel::Syscall::SC_ptrace_params& params, P
|
||||
return KResult(-EBUSY);
|
||||
}
|
||||
peer->start_tracing_from(caller.pid());
|
||||
if (peer->state() != Thread::State::Stopped && !(peer->has_blocker() && peer->blocker().is_reason_signal()))
|
||||
peer->send_signal(SIGSTOP, &caller);
|
||||
if (peer->state() != Thread::State::Stopped) {
|
||||
ScopedSpinLock lock(peer->get_lock());
|
||||
if (!(peer->has_blocker() && peer->blocker().is_reason_signal()))
|
||||
peer->send_signal(SIGSTOP, &caller);
|
||||
}
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user