mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
After marking a thread for death we might end up finalizing the thread while it still has code to run, e.g. via: Thread::block -> Thread::dispatch_one_pending_signal -> Thread::dispatch_signal -> Process::terminate_due_to_signal -> Process::die -> Process::kill_all_threads -> Thread::set_should_die This marks the thread for death. It isn't destroyed at this point though. The scheduler then gets invoked via: Thread::block -> Thread::relock_process At that point we still have a registered blocker on the stack frame which belongs to Thread::block. Thread::relock_process drops the critical section which allows the scheduler to run. When the thread is then scheduled out the scheduler sets the thread state to Thread::Dying which allows the finalizer to destroy the Thread object and its associated resources including the kernel stack. This probably also affects objects other than blockers which rely on their destructor to be run, however the problem was most noticible because blockers are allocated on the stack of the dying thread and cause an access violation when another thread touches the blocker which belonged to the now-dead thread. Fixes #7823.
20 KiB
20 KiB