Loader: resume late faults through recorded console instruction replacements (#2393) #2585

Manually merged
github merged 2 commits from github-bot/gh-2585 into main 2026-11-30 23:41:31 +00:00 AGit
Owner

@⁠fainty0 on GitHub · 2026-11-29 14:39 UTC · original
fainty0:fix/2393-late-console-fault → main · +131 −54 · 1 files · 2 commits · merged 2026-11-30 23:37 UTC

Fixes #2393

What it changes

A late illegal-instruction fault could go unhandled if another thread had already replaced the faulting instruction. The handler now snapshots code under the patch lock and resumes only when the bytes exactly match a replacement it installed at that address. It enters generated stubs directly and retries inline replacements in place. Stubs are flushed before their jumps are installed. The site flush is best-effort: the bytes were already written and must remain recognisable even if the flush fails. CLWB falls back to emulation when it cannot be patched atomically.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): none; no GPU or game used.
  • Before: the handler could not decode the replacement bytes and returned the late fault unhandled.
  • After: Windows cross-target clippy showed no new diagnostics in either workspace gate or either loader-only gate. The CPU-only regression covers insertq, extrq, monitorx, mwaitx, the clzero loop and clwb, and rejects altered or unrecorded bytes. It was type-checked but not run (no Windows); runtime behaviour was not verified.
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): n/a; no shader changes.
  • cargo test passed for the crates it touches: no. Eleven Linux loader unit tests passed; one unchanged PE-only test failed on the Linux test executable with Unknown file magic on both main and the branch. Windows tests were not run (no Windows).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Searches for SSE4a, insertq, 1653, 2393 and console_insn found no open PRs. Related: #1653 (merged).
**@⁠fainty0** on GitHub · 2026-11-29 14:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2585) `fainty0:fix/2393-late-console-fault` → `main` · +131 −54 · 1 files · 2 commits · merged 2026-11-30 23:37 UTC Fixes #2393 ## What it changes A late illegal-instruction fault could go unhandled if another thread had already replaced the faulting instruction. The handler now snapshots code under the patch lock and resumes only when the bytes exactly match a replacement it installed at that address. It enters generated stubs directly and retries inline replacements in place. Stubs are flushed before their jumps are installed. The site flush is best-effort: the bytes were already written and must remain recognisable even if the flush fails. CLWB falls back to emulation when it cannot be patched atomically. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): none; no GPU or game used. - Before: the handler could not decode the replacement bytes and returned the late fault unhandled. - After: Windows cross-target clippy showed no new diagnostics in either workspace gate or either loader-only gate. The CPU-only regression covers `insertq`, `extrq`, `monitorx`, `mwaitx`, the `clzero` loop and `clwb`, and rejects altered or unrecorded bytes. It was type-checked but not run (no Windows); runtime behaviour was not verified. - For shader changes, the wave sizes tested (32 and/or 64 lanes): n/a; no shader changes. - `cargo test` passed for the crates it touches: no. Eleven Linux loader unit tests passed; one unchanged PE-only test failed on the Linux test executable with `Unknown file magic` on both main and the branch. Windows tests were not run (no Windows). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Searches for `SSE4a`, `insertq`, `1653`, `2393` and `console_insn` found no open PRs. Related: #1653 (merged).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 14:44:53 +00:00
Author
Owner

@⁠Kassadd on GitHub · 2026-11-29 15:37 UTC · original

Independent confirmation of the race under Wine, with a runtime result this
branch does not have.

Environment: RTX 4080 SUPER 16 GB, i9-14900K (no SSE4a), CachyOS,
NVIDIA 620.73.04, Series X 1.0.2.1, victory.exe from release v2026.11.29.01.
Two runtimes, same result: GE-Proton 11-14 and Proton Experimental
(experimental-bleeding-edge-11.0-482815-20261128, vkd3d-proton 71cae0).

The same fault, in the same shape as #2614's report. Two run-ending
0xc000001d in a few minutes of play, at different addresses, both with our
own e9 … 90 where a console instruction used to be:

unhandled exception 0xc000001d at victory-image-b99f876b74d4a77f.dll+0x27c8f2
  (code e9 69 3a a0 ff 90 90 c4 e2 79 31 c9 c5 e1 72)

unhandled exception 0xc000001d at victory-image-b99f876b74d4a77f.dll+0x55b1811
  (code e9 4a eb 6c fa 90 c4 e2 79 21 c9 c5 f8 5b c9)

The bytes in the file at those RVAs are f2 44 0f 78 cf 08 00 and
f2 0f 78 c9 08 18: insertq in both cases. So the rip holds our jump, and
only a fault taken on the old bytes explains it, exactly as #2614 says.

A control that settles it without patching any code. This tree already has
VICTORY_PATCH_SSE4A=0, which emulates every time instead of replacing. With
it the crash does not happen at all: a 4-minute run reached 464,947 fences and
the only failure after that was a device lost (0x887A0005), which is a
different problem. Without it, the run ends in 0xc000001d in 1-3 minutes. That
is the race, isolated by a switch: no code touched, no build needed.

And I built your branch and ran it here, on top of #2060/#2160/#2240/#2188
(Rust 1.98.1, cargo-xwin, MSVC target; the merge applied with no conflict):

  • 0xc000001d: gone. Before, a run ended in 1-3 minutes; this one did not
    fault once.
  • In the world: 9.6 to 29.5 fps, ending at 29.5 fps / 33.8 ms with
    5,551-5,661 draws/frame — against 3.7 fps for the same configuration
    before the fix. The spread is the pipeline building, not steady state.
  • The run ended on a device lost (0x887A0005) at fence 243,453 after
    several minutes. That is a separate problem (VRAM), not this one, and it is
    what the game now reaches because the fault no longer stops it.

For comparison, a fix I wrote that only took E9 jumps gave 30.5 fps and 4,773
draws: the same place, so your broader coverage (monitorx/mwaitx/clwb)
costs nothing and closes the cases mine would have left open. Yours is the one
worth taking.

Not the same as the libnvidia-gpucomp crash. docs/linux-proton.md
records a 0xc000001d inside NVIDIA's shader compiler during
vkCreateComputePipelines; that one is avoided by changing Proton. The fault
here is in the title's code and is unchanged by the runtime, which fits the
diagnosis in this PR being platform-independent.

What I did not do: test on Windows, or run it long enough to reach a steady
state past pipeline building. Logs and the exact invocation are available on
request.

**@⁠Kassadd** on GitHub · 2026-11-29 15:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2585#issuecomment-7258233284) Independent confirmation of the race under Wine, with a runtime result this branch does not have. **Environment:** RTX 4080 SUPER 16 GB, i9-14900K (no SSE4a), CachyOS, NVIDIA 620.73.04, Series X `1.0.2.1`, `victory.exe` from release v2026.11.29.01. Two runtimes, same result: **GE-Proton 11-14** and **Proton Experimental** (`experimental-bleeding-edge-11.0-482815-20261128`, vkd3d-proton `71cae0`). **The same fault, in the same shape as #2614's report.** Two run-ending `0xc000001d` in a few minutes of play, at different addresses, both with our own `e9 … 90` where a console instruction used to be: ```text unhandled exception 0xc000001d at victory-image-b99f876b74d4a77f.dll+0x27c8f2 (code e9 69 3a a0 ff 90 90 c4 e2 79 31 c9 c5 e1 72) unhandled exception 0xc000001d at victory-image-b99f876b74d4a77f.dll+0x55b1811 (code e9 4a eb 6c fa 90 c4 e2 79 21 c9 c5 f8 5b c9) ``` The bytes in the file at those RVAs are `f2 44 0f 78 cf 08 00` and `f2 0f 78 c9 08 18`: `insertq` in both cases. So the rip holds our jump, and only a fault taken on the old bytes explains it, exactly as #2614 says. **A control that settles it without patching any code.** This tree already has `VICTORY_PATCH_SSE4A=0`, which emulates every time instead of replacing. With it the crash does not happen at all: a 4-minute run reached 464,947 fences and the only failure after that was a `device lost` (`0x887A0005`), which is a different problem. Without it, the run ends in `0xc000001d` in 1-3 minutes. That is the race, isolated by a switch: no code touched, no build needed. **And I built your branch and ran it here**, on top of #2060/#2160/#2240/#2188 (Rust 1.98.1, cargo-xwin, MSVC target; the merge applied with no conflict): - `0xc000001d`: **gone**. Before, a run ended in 1-3 minutes; this one did not fault once. - In the world: **9.6 to 29.5 fps**, ending at 29.5 fps / 33.8 ms with **5,551-5,661 draws/frame** — against 3.7 fps for the same configuration before the fix. The spread is the pipeline building, not steady state. - The run ended on a `device lost` (`0x887A0005`) at fence 243,453 after several minutes. That is a separate problem (VRAM), not this one, and it is what the game now reaches *because* the fault no longer stops it. For comparison, a fix I wrote that only took `E9` jumps gave 30.5 fps and 4,773 draws: the same place, so your broader coverage (`monitorx`/`mwaitx`/`clwb`) costs nothing and closes the cases mine would have left open. Yours is the one worth taking. **Not the same as the `libnvidia-gpucomp` crash.** `docs/linux-proton.md` records a `0xc000001d` inside NVIDIA's shader compiler during `vkCreateComputePipelines`; that one is avoided by changing Proton. The fault here is in the title's code and is unchanged by the runtime, which fits the diagnosis in this PR being platform-independent. What I did not do: test on Windows, or run it long enough to reach a steady state past pipeline building. Logs and the exact invocation are available on request.
Author
Owner

@⁠tempodat on GitHub · 2026-11-29 18:11 UTC · original

@⁠Kassadd Weirdly enough i just encountered this same crash under wine (following the same docs/linux-proton.md file as a guide). might actually be an indicator that it's a wine/proton specific issue. for future reference adding --set VICTORY_PATCH_SSE4A=0 to the end of the victory.exe play line got around the issue.

**@⁠tempodat** on GitHub · 2026-11-29 18:11 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2585#issuecomment-7260285201) @⁠Kassadd Weirdly enough i just encountered this same crash under wine (following the same `docs/linux-proton.md` file as a guide). might actually be an indicator that it's a wine/proton specific issue. for future reference adding `--set VICTORY_PATCH_SSE4A=0` to the end of the victory.exe play line got around the issue.
Author
Owner

@⁠AimLogin on GitHub · 2026-11-29 19:27 UTC · original

Review note (read from the diff, not run on this branch):

The ordering looks right to me. The replacement is recorded while PATCHING is still held, and emulate copies the fault bytes and does the lookup under the same lock, so a late thread that sees the new bytes always finds the record. The exact byte match means a site that changed again afterwards is not mistaken for ours. #2614 handles the same issue but records after the store and looks up without the patch lock, which leaves a short window open (details there).

Two small points:

  • patch_sse4a now accepts 5–8 bytes instead of 5–16. SSE4a sites of 9–16 bytes, which can occur with extra prefixes, are no longer replaced and go back to one exception per execution. That costs speed, not correctness. If it is intended, a line in the description would help.
  • Since the description says the Windows tests were not run: we implemented the same scheme independently in a local tree (record under the patch lock, exact byte match). On Windows 11, a test that faults a second time at a replaced mwaitx, at the 12-byte clzero loop and at an insertq resumes and writes nothing again. Its control, the old logic without the record, returns the unhandled fault. That supports the design but is not a run of this branch.

Review was AI-assisted.

**@⁠AimLogin** on GitHub · 2026-11-29 19:27 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2585#issuecomment-7261292011) Review note (read from the diff, not run on this branch): The ordering looks right to me. The replacement is recorded while `PATCHING` is still held, and `emulate` copies the fault bytes and does the lookup under the same lock, so a late thread that sees the new bytes always finds the record. The exact byte match means a site that changed again afterwards is not mistaken for ours. #2614 handles the same issue but records after the store and looks up without the patch lock, which leaves a short window open (details there). Two small points: - `patch_sse4a` now accepts 5–8 bytes instead of 5–16. SSE4a sites of 9–16 bytes, which can occur with extra prefixes, are no longer replaced and go back to one exception per execution. That costs speed, not correctness. If it is intended, a line in the description would help. - Since the description says the Windows tests were not run: we implemented the same scheme independently in a local tree (record under the patch lock, exact byte match). On Windows 11, a test that faults a second time at a replaced `mwaitx`, at the 12-byte `clzero` loop and at an `insertq` resumes and writes nothing again. Its control, the old logic without the record, returns the unhandled fault. That supports the design but is not a run of this branch. _Review was AI-assisted._
Author
Owner

@⁠Kassadd on GitHub · 2026-11-29 21:41 UTC · original

Update: rerun on the current tree (v2026.11.29.03). The numbers in my earlier
comment were from v2026.11.29.01, before the 29.02/29.03 hotfixes. This is what
changed.

Built main at cec481f4 (the tree of v2026.11.29.03) with this PR merged on top — it
applied with no conflict — and ran it. Environment unchanged from my earlier comment:
RTX 4080 SUPER 16 GB, i9-14900K (no SSE4a), CachyOS, NVIDIA 620.73.04, Proton
Experimental ...-20261128 (vkd3d-proton 71cae0), Series X 1.0.2.1,
--res 1080to1440, shader cache emptied first as the release notes ask.

  • No 0xc000001d in a 5-minute run at 4,000–11,795 draws/frame. On the same tree
    without this PR a run ends in 0xc000001d within 1–3 minutes, with
    e9 b9 ba 3f fa 90 c4 e2 79 21 c0 at +0x5084782 — the shape #2614 reports. So the
    fault this PR closes is still present in the .03 tree and still reachable in play.
  • 19–29 fps in the world, single samples throughout (I did not take a distribution).
  • About 300 draws a frame still dropped, with 0 being made, constant rather than
    growing. That is not this PR: it also happens with the console-instruction patch
    turned off entirely (VICTORY_PATCH_SSE4A=0), so it is the bind path or the sky miss
    and I have not isolated which.

On attribution, to be precise about what I have. Three runs on this tree:

run duration ended
.03 as released 1–3 min 0xc000001d (SSE4a race)
.03 + this PR only 5m 06s still running when I stopped it; no fault
.03 + this PR + #2455 6m 13s still running when I stopped it; no fault

So this PR alone did carry a run past five minutes, which is why the table is here rather
than a claim; what #2455 adds on top I cannot separate from these numbers. The useful
part is the first line against the other two: the fault fires in 1–3 minutes on the
released tree and did not fire at all with this PR.

What I did not verify: Windows, or a run past the opening. Logs on request.

**@⁠Kassadd** on GitHub · 2026-11-29 21:41 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2585#issuecomment-7263071311) **Update: rerun on the current tree (v2026.11.29.03).** The numbers in my earlier comment were from v2026.11.29.01, before the 29.02/29.03 hotfixes. This is what changed. Built `main` at `cec481f4` (the tree of v2026.11.29.03) with this PR merged on top — it applied with no conflict — and ran it. Environment unchanged from my earlier comment: RTX 4080 SUPER 16 GB, i9-14900K (no SSE4a), CachyOS, NVIDIA 620.73.04, Proton Experimental `...-20261128` (vkd3d-proton `71cae0`), Series X `1.0.2.1`, `--res 1080to1440`, shader cache emptied first as the release notes ask. - **No `0xc000001d`** in a 5-minute run at 4,000–11,795 draws/frame. On the same tree **without** this PR a run ends in `0xc000001d` within 1–3 minutes, with `e9 b9 ba 3f fa 90 c4 e2 79 21 c0` at `+0x5084782` — the shape #2614 reports. So the fault this PR closes is still present in the .03 tree and still reachable in play. - 19–29 fps in the world, single samples throughout (I did not take a distribution). - About 300 draws a frame still dropped, with `0 being made`, constant rather than growing. That is **not** this PR: it also happens with the console-instruction patch turned off entirely (`VICTORY_PATCH_SSE4A=0`), so it is the `bind` path or the sky miss and I have not isolated which. **On attribution, to be precise about what I have.** Three runs on this tree: | run | duration | ended | |---|---:|---| | .03 as released | 1–3 min | `0xc000001d` (SSE4a race) | | .03 + this PR only | 5m 06s | still running when I stopped it; no fault | | .03 + this PR + #2455 | 6m 13s | still running when I stopped it; no fault | So this PR alone did carry a run past five minutes, which is why the table is here rather than a claim; what #2455 adds on top I cannot separate from these numbers. The useful part is the first line against the other two: **the fault fires in 1–3 minutes on the released tree and did not fire at all with this PR.** What I did not verify: Windows, or a run past the opening. Logs on request.
Author
Owner

@⁠gabrielecabrini on GitHub · 2026-11-29 22:08 UTC · original

I closed my #2614 for this one: it fixes the same #2393 without the gap between the store and note_patched that mine left open. +1 for landing this.

**@⁠gabrielecabrini** on GitHub · 2026-11-29 22:08 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2585#issuecomment-7263433828) I closed my #2614 for this one: it fixes the same #2393 without the gap between the store and `note_patched` that mine left open. +1 for landing this.
Author
Owner

@⁠superuser404notfound on GitHub · 2026-11-29 22:25 UTC · original

The Windows unit tests of this branch, run (the description says they were type-checked only).

Environment: i7-13700KF (no SSE4a), RTX 4080, CachyOS kernel 7.3.6, GE-Proton 11-11
(wine-staging 11.0), Series X 1.0.2.1. Built with cargo xwin (Rust 1.98.1, MSVC target) on
main at 716a0c9 with this PR merged on top; the merge applied with no conflict.

Tests: cargo xwin test --release --locked -p victory-loader --lib console_insn, the test
executable run under Wine 11 as the cargo runner: 10 passed, 0 failed, including the new
late_faults_resume_only_through_the_exact_installed_replacement. These are the tests that were
not run anywhere before.

The fault, a third time on other hardware and another Proton: on 716a0c9 without this PR,
a run ended about six minutes in (game frame 57,957) with

VIctory: unhandled exception 0xc000001d at victory-image-b99f876b74d4a77f-p2f9ea84c.dll+0x5084782
  (code e9 79 bb 0f 06 90 c4 e2 79 21 c0 c5 f8 5b c0)

the same site and shape as #2614 and Kassadd's .03 run.

Not done: an in-game run of this branch here (the runtime result above is Kassadd's), or
Windows. Unrelated to this PR, noted only so nobody chases it: crash::tests::concurrent_crash_records_stay_together
fails under Wine on main as well.

Tests run and comment written with Claude Code (AI-assisted).

**@⁠superuser404notfound** on GitHub · 2026-11-29 22:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2585#issuecomment-7263659625) The Windows unit tests of this branch, run (the description says they were type-checked only). **Environment:** i7-13700KF (no SSE4a), RTX 4080, CachyOS kernel 7.3.6, GE-Proton 11-11 (wine-staging 11.0), Series X `1.0.2.1`. Built with `cargo xwin` (Rust 1.98.1, MSVC target) on `main` at `716a0c9` with this PR merged on top; the merge applied with no conflict. **Tests:** `cargo xwin test --release --locked -p victory-loader --lib console_insn`, the test executable run under Wine 11 as the cargo runner: **10 passed, 0 failed**, including the new `late_faults_resume_only_through_the_exact_installed_replacement`. These are the tests that were not run anywhere before. **The fault, a third time on other hardware and another Proton:** on `716a0c9` without this PR, a run ended about six minutes in (game frame 57,957) with ```text VIctory: unhandled exception 0xc000001d at victory-image-b99f876b74d4a77f-p2f9ea84c.dll+0x5084782 (code e9 79 bb 0f 06 90 c4 e2 79 21 c0 c5 f8 5b c0) ``` the same site and shape as #2614 and Kassadd's `.03` run. Not done: an in-game run of this branch here (the runtime result above is Kassadd's), or Windows. Unrelated to this PR, noted only so nobody chases it: `crash::tests::concurrent_crash_records_stay_together` fails under Wine on `main` as well. _Tests run and comment written with Claude Code (AI-assisted)._
Author
Owner

@⁠Kassadd on GitHub · 2026-11-30 00:23 UTC · original

The fault is still there on v2026.11.29.05, which is the point: this PR has to
reach main to have any effect, and each release since .01 has shipped without it.

Ran the released v2026.11.29.05 binary (SHA-256
80612b22a3cb7650…) with no patches, same machine and Proton Experimental as my
comment above. It died on the way into the world with

unhandled exception 0xc000001d at victory-image-b99f876b74d4a77f-p2f9ea84c.dll+0x5084782
  (code e9 b9 ba bf fa 90 c4 e2 79 21 c0 c5 f8 5b c0)

+0x5084782 again — the same site and shape as #2614, as superuser404notfound's run
on 716a0c9, and as my .03 run. Then main (41adb551, the .05 tree) with this PR and #2455 merged
ran for over four minutes in the world at 17-18 fps and 6,077 draws a frame, with no
0xc000001d in the log at all. So .04 and .05 changed neither the bug nor its address.

That is why I think this one should not wait for a quiet moment: every release the
Linux users get is a build where the opening dies at random, and the only alternative
they have is VICTORY_PATCH_SSE4A=0, which emulates every SSE4a instruction instead of
replacing it — measurably slower, and it leaves the monitorx/mwaitx half of the
race open (as this PR's own description says).

Nothing new about the code itself; the tests above and gabrielecabrini's and
superuser404notfound's reports cover that ground better than I could.

**@⁠Kassadd** on GitHub · 2026-11-30 00:23 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2585#issuecomment-7265233930) **The fault is still there on v2026.11.29.05**, which is the point: this PR has to reach `main` to have any effect, and each release since .01 has shipped without it. Ran the released `v2026.11.29.05` binary (SHA-256 `80612b22a3cb7650…`) with no patches, same machine and Proton Experimental as my comment above. It died on the way into the world with ```text unhandled exception 0xc000001d at victory-image-b99f876b74d4a77f-p2f9ea84c.dll+0x5084782 (code e9 b9 ba bf fa 90 c4 e2 79 21 c0 c5 f8 5b c0) ``` `+0x5084782` again — the same site and shape as #2614, as superuser404notfound's run on 716a0c9, and as my .03 run. Then `main` (`41adb551`, the .05 tree) with this PR and #2455 merged ran for over four minutes in the world at 17-18 fps and 6,077 draws a frame, with no `0xc000001d` in the log at all. So .04 and .05 changed neither the bug nor its address. That is why I think this one should not wait for a quiet moment: every release the Linux users get is a build where the opening dies at random, and the only alternative they have is `VICTORY_PATCH_SSE4A=0`, which emulates every SSE4a instruction instead of replacing it — measurably slower, and it leaves the `monitorx`/`mwaitx` half of the race open (as this PR's own description says). Nothing new about the code itself; the tests above and gabrielecabrini's and superuser404notfound's reports cover that ground better than I could.
Author
Owner

@⁠Kassadd on GitHub · 2026-11-30 14:54 UTC · original · edited 2026-11-30 14:55 UTC

@⁠tempodat — thanks for confirming it under Wine, another independent report at the same site.

But VICTORY_PATCH_SSE4A=0 is a workaround, not a fix: it emulates every SSE4a instruction
instead of replacing it, and it leaves the monitorx/mwaitx half of the race open.

You no longer need to wait for anything. main has had this fix since 1cdcb94, co-authored
by @⁠fainty0 — the same change, landed 26 minutes before this PR was opened. I built main at
c71899d with no patch: no 0xc000001d. Drop the switch and get the speed back.


On closing this PR — the remaining diff against main is one line:

-    flush_code(at, len);
+    let _ = flush_code(at, len);

Everything else is already in main point for point, which is what this thread's four reports
were measuring. That line is a real improvement — if the flush fails the bytes are still written,
so aborting the record loses them — but it does not need 131 lines, and a merge would land it
under a description that no longer matches.

The thread is now doing the opposite of what it was written for: two people have concluded they
need a fork build or the slow switch. Neither is true.

My suggestion: close this one, keeping the credit for the diagnosis, and open a small PR with that
line plus a test where flush_code is made to fail. If you would rather merge it as a one-liner,
that is fine too — the fix lands either way.

Not tested by me: Windows, and the failing-flush path itself.

**@⁠Kassadd** on GitHub · 2026-11-30 14:54 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2585#issuecomment-7282108606) · edited 2026-11-30 14:55 UTC @⁠tempodat — thanks for confirming it under Wine, another independent report at the same site. But `VICTORY_PATCH_SSE4A=0` is a workaround, not a fix: it emulates every SSE4a instruction instead of replacing it, and it leaves the `monitorx`/`mwaitx` half of the race open. **You no longer need to wait for anything.** `main` has had this fix since `1cdcb94`, co-authored by @⁠fainty0 — the same change, landed 26 minutes *before* this PR was opened. I built `main` at `c71899d` with no patch: no `0xc000001d`. Drop the switch and get the speed back. --- **On closing this PR** — the remaining diff against `main` is one line: ```diff - flush_code(at, len); + let _ = flush_code(at, len); ``` Everything else is already in `main` point for point, which is what this thread's four reports were measuring. That line is a real improvement — if the flush fails the bytes are still written, so aborting the record loses them — but it does not need 131 lines, and a merge would land it under a description that no longer matches. The thread is now doing the opposite of what it was written for: two people have concluded they need a fork build or the slow switch. Neither is true. My suggestion: close this one, keeping the credit for the diagnosis, and open a small PR with that line plus a test where `flush_code` is made to fail. If you would rather merge it as a one-liner, that is fine too — the fix lands either way. Not tested by me: Windows, and the failing-flush path itself.
Author
Owner

@⁠iBooM72 on GitHub · 2026-11-30 20:43 UTC · original

Correction to the comment above: this fix isn't in main yet. I checked c71899d9 (the version tested there) and current main, e1251c31.

  • 1cdcb94 is this PR's own first commit. It isn't in the history of either version. The one-line difference is between that commit and this PR's head (87ddb293), not between main and this PR.
  • In both versions, console_insn.rs is identical to the one in 829188e9 (v2026.11.29.01). Merging this PR into e1251c31 gives no conflicts and changes that file by +131/-54 lines.
  • The only other change to victory-loader between 829188e9 and e1251c31 is ea97b1af, which only builds unwind_copy when diagnostics is on.

The crash depends on timing, so a run without 0xc000001d doesn't show that it's fixed. On 829188e9, my stress test crashed with 0xc000001d in all 200 runs. That test is much harsher than the game, and I haven't rerun it on current main.

Until a fix is merged, I'd keep VICTORY_PATCH_SSE4A=0 if you're using it to avoid this crash. It's a workaround with a speed cost I haven't measured, and it doesn't cover the clzero, monitorx/mwaitx or clwb replacements.

Please don't close this PR because the fix is thought to be in main. In my test, it removed 0xc000001d, but 253 of 20,000 runs still crashed with other errors, so it's a big improvement but not a complete fix.

These checks and this comment were prepared with an AI assistant (Claude Code).

**@⁠iBooM72** on GitHub · 2026-11-30 20:43 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2585#issuecomment-7291387301) **Correction to the [comment above](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/2585): this fix isn't in `main` yet.** I checked `c71899d9` (the version tested there) and current `main`, `e1251c31`. - `1cdcb94` is this PR's own first commit. It isn't in the history of either version. The one-line difference is between that commit and this PR's head (`87ddb293`), not between `main` and this PR. - In both versions, `console_insn.rs` is identical to the one in `829188e9` (v2026.11.29.01). Merging this PR into `e1251c31` gives no conflicts and changes that file by +131/-54 lines. - The only other change to `victory-loader` between `829188e9` and `e1251c31` is `ea97b1af`, which only builds `unwind_copy` when `diagnostics` is on. The crash depends on timing, so a run without `0xc000001d` doesn't show that it's fixed. On `829188e9`, [my stress test](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/issues/2393) crashed with `0xc000001d` in all 200 runs. That test is much harsher than the game, and I haven't rerun it on current `main`. **Until a fix is merged, I'd keep `VICTORY_PATCH_SSE4A=0` if you're using it to avoid this crash.** It's a workaround with a speed cost I haven't measured, and it doesn't cover the `clzero`, `monitorx`/`mwaitx` or `clwb` replacements. Please don't close this PR because the fix is thought to be in `main`. In my test, it removed `0xc000001d`, but 253 of 20,000 runs still crashed with other errors, so it's a big improvement but not a complete fix. *These checks and this comment were prepared with an AI assistant (Claude Code).*
Author
Owner

@⁠Kassadd on GitHub · 2026-11-30 20:47 UTC · original

@⁠iBooM72 is right and I was wrong. Correcting it here so nobody closes this PR on my account.

What I got wrong. I wrote that this fix has been in main since 1cdcb94. It has not —
1cdcb94 is this PR's own first commit. I fetched the PR branch, merged it, and then read
git log on a tree that already contained it, so the commit looked like it belonged to main.
git merge-base --is-ancestor 1cdcb94 origin/main says no, and the history of
crates/victory-loader/src/console_insn.rs on main ends at baaace8 (#3482), which is not
this.

The "one line" figure was wrong the same way. The one-line difference I found
(let _ = flush_code(..)) is between 1cdcb94 and this PR's head, not between main and this
PR. Against main the diff is the whole +131/−54, as @⁠iBooM72 says.

And my "ran main with no 0xc000001d" proved nothing. The race is a timing race: a clean
run is not evidence of a fix, which I should have known from the four reports in this thread all
needing minutes of play to hit it.

What settles it is a crash I can now reproduce on current main. On e1251c3 (2026-11-30
evening), a 3440x1440 run under Proton ended with:

unhandled exception 0xc000001d at victory-image-b99f876b74d4a77f-p2f9ea84c.dll+0x5084782
  (code e9 b9 ba bf fa 90 c4 e2 79)

+0x5084782, with our own e9 in the bytes — the same site and shape as #2614's report, this
PR's own description, and @⁠superuser404notfound's run. That was without this PR and
without VICTORY_PATCH_SSE4A=0. So the fault is still reachable on the tree people are
shipping and playing today, and it is not a main-has-it-already situation.

So: do not close this. It did not land, and it is still needed. My earlier suggestion was
wrong on both counts and I have nothing to add to @⁠iBooM72's measurements, which are better than
mine.

One thing worth knowing for whoever merges it, since it bit me: until this is in main,
a build that runs clean for ten minutes is not evidence. The three runs I based my wrong
conclusion on all happened to survive, and the next one crashed. If a fix like this needs a
"does it hold" answer, the stress test @⁠iBooM72 describes is the only thing that answers it.

**@⁠Kassadd** on GitHub · 2026-11-30 20:47 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2585#issuecomment-7291478991) @⁠iBooM72 is right and I was wrong. Correcting it here so nobody closes this PR on my account. **What I got wrong.** I wrote that this fix has been in `main` since `1cdcb94`. It has not — `1cdcb94` is **this PR's own first commit**. I fetched the PR branch, merged it, and then read `git log` on a tree that already contained it, so the commit looked like it belonged to `main`. `git merge-base --is-ancestor 1cdcb94 origin/main` says no, and the history of `crates/victory-loader/src/console_insn.rs` on `main` ends at `baaace8` (#3482), which is not this. **The "one line" figure was wrong the same way.** The one-line difference I found (`let _ = flush_code(..)`) is between `1cdcb94` and this PR's head, not between `main` and this PR. Against `main` the diff is the whole **+131/−54**, as @⁠iBooM72 says. **And my "ran `main` with no `0xc000001d`" proved nothing.** The race is a timing race: a clean run is not evidence of a fix, which I should have known from the four reports in this thread all needing minutes of play to hit it. **What settles it is a crash I can now reproduce on current `main`.** On `e1251c3` (2026-11-30 evening), a 3440x1440 run under Proton ended with: ```text unhandled exception 0xc000001d at victory-image-b99f876b74d4a77f-p2f9ea84c.dll+0x5084782 (code e9 b9 ba bf fa 90 c4 e2 79) ``` `+0x5084782`, with our own `e9` in the bytes — the same site and shape as #2614's report, this PR's own description, and @⁠superuser404notfound's run. That was **without** this PR and **without** `VICTORY_PATCH_SSE4A=0`. So the fault is still reachable on the tree people are shipping and playing today, and it is not a `main`-has-it-already situation. **So: do not close this.** It did not land, and it is still needed. My earlier suggestion was wrong on both counts and I have nothing to add to @⁠iBooM72's measurements, which are better than mine. **One thing worth knowing for whoever merges it**, since it bit me: until this is in `main`, **a build that runs clean for ten minutes is not evidence**. The three runs I based my wrong conclusion on all happened to survive, and the next one crashed. If a fix like this needs a "does it hold" answer, the stress test @⁠iBooM72 describes is the only thing that answers it.
github manually merged commit 36216e5845 into main 2026-11-30 23:41:31 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/trustno1-coder--VIctory-NVIDIA!2585
No description provided.