From 52f58e64efbf43c114f701eb8f39fb463138ffb8 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 31 Jan 2015 23:26:16 -0200 Subject: Kernel: Make WaitObjects share ownership of Threads waiting on them During normal operation, a thread waiting on an WaitObject and the object hold mutual references to each other for the duration of the wait. If a process is forcefully terminated (The CTR kernel has a SVC to do this, TerminateProcess, though no equivalent exists for threads.) its threads would also be stopped and destroyed, leaving dangling pointers in the WaitObjects. The solution is to simply have the Thread remove itself from WaitObjects when it is stopped. The vector of Threads in WaitObject has also been changed to hold SharedPtrs, just in case. (Better to have a reference cycle than a crash.) --- src/core/hle/kernel/thread.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/hle/kernel/thread.h') diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 980c2613..633bb7c9 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -134,6 +134,8 @@ private: Handle callback_handle; }; +extern SharedPtr g_main_thread; + /// Sets up the primary application thread SharedPtr SetupMainThread(s32 priority, u32 stack_size); -- cgit v1.2.3