From e91740cf29248bfbf2f059ac7e42159e8e7e9e9a Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sun, 22 Jun 2025 23:34:14 +0200 Subject: [PATCH] coreinit: Make sure thread deallocation runs before join returns Fixes crash in Coaster Crazy Deluxe --- src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp index 2eef929d..2f89000b 100644 --- a/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp +++ b/src/Cafe/OS/libs/coreinit/coreinit_Thread.cpp @@ -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();