Fix/windows condvar stale wake guard#4123
Fix/windows condvar stale wake guard#4123w1naenator wants to merge 4 commits intoshadps4-emu:mainfrom
Conversation
w1naenator
commented
Mar 13, 2026
- Added a non-alertable zero-time semaphore acquire path for wake draining on Windows.
- Added wait-generation tracking per thread and generation-aware deferred wake entries.
- Changed wake delivery so a wake is released only if waiter generation still matches (prevents stale wake release).
- Added stale carryover filtering in wait loop for the N→N+1 wake-token race window.
- Added a non-alertable zero-time semaphore acquire path for wake draining on Windows. - Added wait-generation tracking per thread and generation-aware deferred wake entries. - Changed wake delivery so a wake is released only if waiter generation still matches (prevents stale wake release). - Added stale carryover filtering in wait loop for the N→N+1 wake-token race window. What this fixes: - Prevents obsolete wake tokens from corrupting condvar state on Windows. - Removes the need for workaround behavior that masked unexpected wakes. - Restores stable wait/wake behavior while staying close to original main style.
|
This fixes a random crash in the Ratchet and Clank title on the Windows emulator build. |
|
For the record, the condvar issues are present cross platform, it's not just a Windows bug. I'll do some tests when I can to check the condvar issues on Windows and Linux. |
|
I've yet to run into any condvar unreachables on Windows with this PR. I do still hit them on Linux though. |
On my Ubuntu machine (with different hardware than my Windows system), Ratchet and Clank runs stable and I have not encountered the condvar crash there. If you have a list of titles that still trigger the condvar issue on Linux, please share them. I can try reproducing the problem on my system and report back. |
|
I’m surprised that the emulator runs much more stably on an NVIDIA Quadro T2000 Max-Q with an Intel Core i9-10885H than on a NVIDIA GeForce RTX 3070 Ti Laptop GPU with a 12th Gen Intel Core i9-12900H. |
|
The affected games between platforms are identical. My go-tos for testing were always Uncharted: The Nathan Drake Collection and Marvel's Spider-Man. |
|
No regressions in my titles. |

