Kernel: destruct thread/timer managers after processes (#4399)

Processes can keep some Thread/Timer object alive while the manager is already destructed, resulting use-after-free in Thread::Stop and Timer::dtor. To resolve this, the manager objects should be destructed after all related object destructed.
Fixes a bug where quiting citra causes crash while the game is using a Timer.
This commit is contained in:
Weiyi Wang 2018-11-04 04:24:37 -05:00 committed by Ben
parent 7c3d325aff
commit 57e1f47a52
1 changed files with 3 additions and 3 deletions

View File

@ -228,6 +228,9 @@ private:
std::unique_ptr<ResourceLimitList> resource_limits;
std::atomic<u32> next_object_id{0};
std::unique_ptr<ThreadManager> thread_manager;
std::unique_ptr<TimerManager> timer_manager;
// TODO(Subv): Start the process ids from 10 for now, as lower PIDs are
// reserved for low-level services
u32 next_process_id = 10;
@ -237,9 +240,6 @@ private:
SharedPtr<Process> current_process;
std::unique_ptr<ThreadManager> thread_manager;
std::unique_ptr<TimerManager> timer_manager;
std::unique_ptr<ConfigMem::Handler> config_mem_handler;
std::unique_ptr<SharedPage::Handler> shared_page_handler;
};