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.)
This commit is contained in:
parent
7725256f64
commit
52f58e64ef
6 changed files with 17 additions and 12 deletions
|
@ -110,6 +110,9 @@ void Thread::Stop(const char* reason) {
|
|||
WakeupAllWaitingThreads();
|
||||
|
||||
// Stopped threads are never waiting.
|
||||
for (auto& wait_object : wait_objects) {
|
||||
wait_object->RemoveWaitingThread(this);
|
||||
}
|
||||
wait_objects.clear();
|
||||
wait_address = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue