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.
This commit is contained in:
Valdis Bogdāns 2026-02-14 02:32:50 +02:00 committed by GitHub
parent e0850d5cfc
commit 2f885b6c21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -59,9 +59,11 @@ void ClearStack() {
template <class ReturnType, class... FuncArgs, class... CallArgs>
ReturnType ExecuteGuest(PS4_SYSV_ABI ReturnType (*func)(FuncArgs...), CallArgs&&... args) {
EnsureThreadInitialized();
// clear stack to avoid trash from EnsureThreadInitialized
ClearStack<12_KB>();
// clear stack to avoid trash from EnsureThreadInitialized (skip on fiber stacks)
auto* tcb = GetTcbBase();
if (tcb == nullptr || tcb->tcb_fiber == nullptr) {
ClearStack<12_KB>();
}
return func(std::forward<CallArgs>(args)...);
}