coreinit: Make sure thread deallocation runs before join returns
Some checks failed
Generate translation template / generate-pot (push) Failing after 36s
Build check / build (push) Has been cancelled

Fixes crash in Coaster Crazy Deluxe
This commit is contained in:
Exzap 2025-06-22 23:34:14 +02:00
parent 4f4c9594ac
commit e91740cf29

View file

@ -717,7 +717,10 @@ namespace coreinit
thread->id = 0x8000;
if (!thread->deallocatorFunc.IsNull())
{
__OSQueueThreadDeallocation(thread);
PPCCore_switchToSchedulerWithLock(); // make sure the deallocation function runs before we return
}
__OSUnlockScheduler();
@ -1525,7 +1528,7 @@ namespace coreinit
}
// queue thread deallocation to run after current thread finishes
// the termination threads run at a higher priority on the same threads
// the termination threads run at a higher priority on the same core
void __OSQueueThreadDeallocation(OSThread_t* thread)
{
uint32 coreIndex = OSGetCoreId();