From 0f92285e5071a788bd078f1c1c7210f2506fdd91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valdis=20Bogd=C4=81ns?= Date: Sat, 14 Feb 2026 23:30:09 +0200 Subject: [PATCH] GR2-win-crash-fix (#4033) * Improve stack clearing logic in ExecuteGuest Added a check for fiber stacks before clearing the stack in ExecuteGuest. That fixes Gravity Rush 2 crash on Windows. * Refactor ExecuteGuest to simplify stack clearing logic This enough for GR2 * Recover thread initialization in ExecuteGuest function * Enhance null check for thread control block * Fix condition to check tcb before clearing stack --- src/core/tls.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/tls.h b/src/core/tls.h index 83940be7a..27de518ea 100644 --- a/src/core/tls.h +++ b/src/core/tls.h @@ -61,7 +61,10 @@ template ReturnType ExecuteGuest(PS4_SYSV_ABI ReturnType (*func)(FuncArgs...), CallArgs&&... args) { EnsureThreadInitialized(); // clear stack to avoid trash from EnsureThreadInitialized - ClearStack<12_KB>(); + auto* tcb = GetTcbBase(); + if (tcb != nullptr && tcb->tcb_fiber == nullptr) { + ClearStack<12_KB>(); + } return func(std::forward(args)...); }