tools: wake-race.sh, a check for Wine's wait-on-address wake race (random crash in RtlWakeAddressSingle) #266

Closed
opened 2026-12-02 22:38:44 +00:00 by github-bot · 0 comments
Owner

@⁠TreXito on GitHub · 2026-12-02 22:38 UTC · original

What happens

At a random moment (three times here: under a minute, 57 minutes and 71 minutes into the world) the game dies with an access violation inside Wine's ntdll.dll, in RtlWakeAddressSingle, reading a near-null address. The caller each time was one of our list threads (victory_gpu::list::thin::Recording::run, releasing a std Mutex), but the caller is only the victim: the queue of waiters it walks was damaged earlier by some other wake.

The same damage can also show as a freeze (a thread walks the damaged queue while it holds the queue's spin lock, and every other thread spins behind it).

Neither #142 nor #184 is this one; I found no report of it here.

Cause

A Wine bug, not VIctory's. In dlls/ntdll/sync.c, RtlWakeAddressSingle() and RtlWakeAddressAll() cleared entry->addr before list_remove(). RtlWaitOnAddress() looks at entry.addr without the lock when it wakes. A waiter that wakes on its own (timeout, or an alert left over from an earlier wake) inside that window sees NULL and returns; its stack, where the entry lies, is used again; the waker then finishes the unlink through whatever is there now.

Wine fixed it in 81e52628b ("ntdll: Make sure entry is removed from queue if unlocked entry.addr precheck in RtlWaitOnAddress() suggests so.", 2026-10-14): unlink first, then clear addr with a release store.

Rust's std locks, Condvar and thread parking all sit on WaitOnAddress / WakeByAddress* on Windows, and VIctory runs many threads on contended locks, so it triggers it well.

Which runtimes have it

By the order of the stores in RtlWakeAddressSingle of each build's ntdll.dll:

Runtime Has the fix
GE-Proton10-32 no
GE-Proton10-34 no
GE-Proton11-7 no
Proton 11.0-3 no
Proton Hotfix (2026-11-10) yes
Proton Experimental (11.0-20261112) yes

env.sh takes the first GE-Proton* it finds, and every GE build above is affected. Note that moving to another Proton can change the pipelines' fingerprint, so the first play after it prepares them all again.

This change

  • tools/wake-race.c: a stress. 24 waiters with timeouts of 10 to 70 µs and 12 wakers on four addresses; it ends with code 2 when the counters stand still for two seconds.
  • tools/wake-race.sh [SECONDS]: builds it with x86_64-w64-mingw32-gcc and runs it on the Wine and prefix that env.sh picks. It changes nothing in the prefix.
  • README: a short "Wine" section that names the symptom, the Wine commit and the tool.

Nothing in the game's path changes.

Tested

Runtime Result
GE-Proton10-34 stood still after 4, 8, 14 and 16 s (4 of 4 runs)
Proton Experimental (11.0-20261112) ran to the end: 45, 20 and 20 s (3 of 3)
GE-Proton10-34 with only the order of those stores changed in the two wake functions of ntdll.dll ran to the end: 45, 30, 30 and 30 s (4 of 4)

On the last one the game boots as before (same fingerprint, nothing to prepare again, same frame rate in the same scene). Whether the crash is gone in play needs hours of play to say; the stress result is what I can show now.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WNCfbX5dPKJzSkgbf16GX4

Pull request details or commits were not available from GitHub; kept as an issue.

**@⁠TreXito** on GitHub · 2026-12-02 22:38 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/266) ### What happens At a random moment (three times here: under a minute, 57 minutes and 71 minutes into the world) the game dies with an access violation inside Wine's `ntdll.dll`, in `RtlWakeAddressSingle`, reading a near-null address. The caller each time was one of our list threads (`victory_gpu::list::thin::Recording::run`, releasing a std `Mutex`), but the caller is only the victim: the queue of waiters it walks was damaged earlier by some other wake. The same damage can also show as a freeze (a thread walks the damaged queue while it holds the queue's spin lock, and every other thread spins behind it). Neither #142 nor #184 is this one; I found no report of it here. ### Cause A Wine bug, not VIctory's. In `dlls/ntdll/sync.c`, `RtlWakeAddressSingle()` and `RtlWakeAddressAll()` cleared `entry->addr` **before** `list_remove()`. `RtlWaitOnAddress()` looks at `entry.addr` without the lock when it wakes. A waiter that wakes on its own (timeout, or an alert left over from an earlier wake) inside that window sees `NULL` and returns; its stack, where the entry lies, is used again; the waker then finishes the unlink through whatever is there now. Wine fixed it in `81e52628b` ("ntdll: Make sure entry is removed from queue if unlocked entry.addr precheck in RtlWaitOnAddress() suggests so.", 2026-10-14): unlink first, then clear `addr` with a release store. Rust's std locks, `Condvar` and thread parking all sit on `WaitOnAddress` / `WakeByAddress*` on Windows, and VIctory runs many threads on contended locks, so it triggers it well. ### Which runtimes have it By the order of the stores in `RtlWakeAddressSingle` of each build's `ntdll.dll`: | Runtime | Has the fix | |---|---| | GE-Proton10-32 | no | | GE-Proton10-34 | no | | GE-Proton11-7 | no | | Proton 11.0-3 | no | | Proton Hotfix (2026-11-10) | yes | | Proton Experimental (11.0-20261112) | yes | `env.sh` takes the first `GE-Proton*` it finds, and every GE build above is affected. Note that moving to another Proton can change the pipelines' fingerprint, so the first `play` after it prepares them all again. ### This change - `tools/wake-race.c`: a stress. 24 waiters with timeouts of 10 to 70 µs and 12 wakers on four addresses; it ends with code 2 when the counters stand still for two seconds. - `tools/wake-race.sh [SECONDS]`: builds it with `x86_64-w64-mingw32-gcc` and runs it on the Wine and prefix that `env.sh` picks. It changes nothing in the prefix. - README: a short "Wine" section that names the symptom, the Wine commit and the tool. Nothing in the game's path changes. ### Tested | Runtime | Result | |---|---| | GE-Proton10-34 | stood still after 4, 8, 14 and 16 s (4 of 4 runs) | | Proton Experimental (11.0-20261112) | ran to the end: 45, 20 and 20 s (3 of 3) | | GE-Proton10-34 with only the order of those stores changed in the two wake functions of `ntdll.dll` | ran to the end: 45, 30, 30 and 30 s (4 of 4) | On the last one the game boots as before (same fingerprint, nothing to prepare again, same frame rate in the same scene). Whether the crash is gone in play needs hours of play to say; the stress result is what I can show now. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WNCfbX5dPKJzSkgbf16GX4 *Pull request details or commits were not available from GitHub; kept as an issue.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 22:38:44 +00:00
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/lobomfz--VIctory-xmem#266
No description provided.