Link victory.exe with a 16 MiB default thread stack #151

Open
github-bot wants to merge 1 commit from github-bot/gh-151 into main AGit
Owner

@⁠ItsYusei99 on GitHub · 2026-11-24 00:58 UTC · original
ItsYusei99:fix/default-thread-stack → main · +11 −0 · 1 files · 1 commits · open

Threads that are created without a stack size get the size the executable's header names, and the linker's default is 1 MiB. The host graphics stack creates such threads: vkd3d-proton's own threads and the driver's. When they compile the title's large world shaders, 1 MiB is not always enough.

Under Wine with vkd3d-proton on an RTX 4070 (driver 620.70.06), loading into the world overflowed the stack of four of those threads at once, all at the same Unix-side address in the driver. One of them was vkd3d-proton's pipeline-library disk thread:

01c8:err:virtual:virtual_setup_exception stack overflow 1792 bytes addr 0x6f44ef27e623 stack 0x10da4c0900 (0x10da4c0000-0x10da4c1000-0x10da5c0000)
01d8:err:virtual:virtual_setup_exception stack overflow 2880 bytes addr 0x6f44ef27e623 stack 0x10dcd604c0 (0x10dcd60000-0x10dcd61000-0x10dce60000)

apps/victory/build.rs now passes /STACK:16777216 to the linker for MSVC targets only. That is a reservation: pages are committed as they are used, so threads that stay shallow cost nothing extra. Threads that ask for an explicit size, such as Rust's std::thread with its 2 MiB default, are unaffected.

Tested

Linux, Wine 11.22, RTX 4070, Ryzen 7 9800X3D, title loaded by hand into the world. I checked the header field of the built exe (SizeOfStackReserve = 16777216, release and diag).

  • Before: 1 MiB stacks, four stack overflows during the world load (one run).
  • After: no stack overflow in a run that reached further into pipeline creation (one run).

Caveat: the "after" run was on a newer main that also includes #43. That PR fixes a stack overflow inside VIctory's shader lowering, which is a different place from the driver address above. I have not yet isolated the two with an A/B run on the same commit. The run then hit a separate driver fault in vkCreateComputePipelines (0xc0000005), reported in #144.

Not tested on native Windows. On Windows the same thread pools exist, so a larger reserve should be harmless there.

🤖 Generated with Claude Code

**@⁠ItsYusei99** on GitHub · 2026-11-24 00:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/151) `ItsYusei99:fix/default-thread-stack` → `main` · +11 −0 · 1 files · 1 commits · open Threads that are created without a stack size get the size the executable's header names, and the linker's default is 1 MiB. The host graphics stack creates such threads: vkd3d-proton's own threads and the driver's. When they compile the title's large world shaders, 1 MiB is not always enough. Under Wine with vkd3d-proton on an RTX 4070 (driver 620.70.06), loading into the world overflowed the stack of four of those threads at once, all at the same Unix-side address in the driver. One of them was vkd3d-proton's pipeline-library disk thread: ``` 01c8:err:virtual:virtual_setup_exception stack overflow 1792 bytes addr 0x6f44ef27e623 stack 0x10da4c0900 (0x10da4c0000-0x10da4c1000-0x10da5c0000) 01d8:err:virtual:virtual_setup_exception stack overflow 2880 bytes addr 0x6f44ef27e623 stack 0x10dcd604c0 (0x10dcd60000-0x10dcd61000-0x10dce60000) ``` `apps/victory/build.rs` now passes `/STACK:16777216` to the linker for MSVC targets only. That is a reservation: pages are committed as they are used, so threads that stay shallow cost nothing extra. Threads that ask for an explicit size, such as Rust's `std::thread` with its 2 MiB default, are unaffected. ### Tested Linux, Wine 11.22, RTX 4070, Ryzen 7 9800X3D, title loaded by hand into the world. I checked the header field of the built exe (`SizeOfStackReserve` = 16777216, release and diag). - Before: 1 MiB stacks, four stack overflows during the world load (one run). - After: no stack overflow in a run that reached further into pipeline creation (one run). Caveat: the "after" run was on a newer `main` that also includes #43. That PR fixes a stack overflow inside VIctory's shader lowering, which is a different place from the driver address above. I have not yet isolated the two with an A/B run on the same commit. The run then hit a separate driver fault in `vkCreateComputePipelines` (`0xc0000005`), reported in #144. Not tested on native Windows. On Windows the same thread pools exist, so a larger reserve should be harmless there. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Threads created without a stack size take the executable's default
reserve, 1 MiB from the linker. vkd3d-proton's and the driver's own
threads compiling the title's large world shaders overflowed it under
Wine on an RTX 4070 (four threads at one driver address during the world
load). Reserve 16 MiB for MSVC targets; pages are committed only as used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:52:18 +00:00
Author
Owner

@⁠NathansDomainSolutions on GitHub · 2026-11-24 04:28 UTC · original

An A/B test on Linux, with both runs on main d2a4bae. The only difference is this PR's build.rs change. I checked the built exe: SizeOfStackReserve is 16777216 with the PR and 1048576 without it.

Setup: Arch (kernel 7.3.5), Proton Experimental experimental-11.0-20261112, RTX 4070 on driver 620.73.04, Ryzen 7 7800X3D, title 1.0.2.1. Diag build cross-compiled with cargo-xwin 0.24.1. Run offline with a scripted Enter press every 8 s (VICTORY_KEYS).

  • Without the PR: passed the player prompt and the first-boot "Finish setup?" screen, and showed a loading spinner. About 3.5 min in it was back at the player prompt. The process exited at about 4 min with nothing in crashes.log. Wine debug output wasn't captured in this run, so I can't confirm it was a stack overflow.
  • With the PR (next run, settings saved): reached the loading-screen artwork at frame 1024, past where the run without the PR stopped. At about 2 min, the frame after 2047, it hung on err:vulkan:vkCreateComputePipelines Exception 0xc0000005 in Unix call. This is the driver fault from #144. There was no stack overflow line in the Wine err output (WINEDEBUG=err+all).

So the PR moves the failure from a silent exit to #144's driver fault. One caveat: the second run started with saved settings, so the two runs didn't take exactly the same path.

AI use: Claude Code (Claude Opus 5.5) ran the builds and runs and wrote this comment. The results come from the runs described above.

**@⁠NathansDomainSolutions** on GitHub · 2026-11-24 04:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/151#issuecomment-7122049268) An A/B test on Linux, with both runs on `main` `d2a4bae`. The only difference is this PR's `build.rs` change. I checked the built exe: `SizeOfStackReserve` is 16777216 with the PR and 1048576 without it. **Setup:** Arch (kernel 7.3.5), Proton Experimental `experimental-11.0-20261112`, RTX 4070 on driver 620.73.04, Ryzen 7 7800X3D, title 1.0.2.1. Diag build cross-compiled with cargo-xwin 0.24.1. Run offline with a scripted Enter press every 8 s (`VICTORY_KEYS`). - **Without the PR:** passed the player prompt and the first-boot "Finish setup?" screen, and showed a loading spinner. About 3.5 min in it was back at the player prompt. The process exited at about 4 min with nothing in `crashes.log`. Wine debug output wasn't captured in this run, so I can't confirm it was a stack overflow. - **With the PR (next run, settings saved):** reached the loading-screen artwork at frame 1024, past where the run without the PR stopped. At about 2 min, the frame after 2047, it hung on `err:vulkan:vkCreateComputePipelines Exception 0xc0000005 in Unix call`. This is the driver fault from #144. There was no `stack overflow` line in the Wine `err` output (`WINEDEBUG=err+all`). So the PR moves the failure from a silent exit to #144's driver fault. One caveat: the second run started with saved settings, so the two runs didn't take exactly the same path. AI use: Claude Code (Claude Opus 5.5) ran the builds and runs and wrote this comment. The results come from the runs described above.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:27 UTC · original

Automated triage for the maintainers.

Needs work: needs the maintainer's decision. This adds a new apps/victory/build.rs that passes /STACK:16777216 to the linker for MSVC targets. Build scripts and linker settings are the maintainer's call. The change is small and only raises the reserve for threads created without an explicit size. What would help that decision: (1) an A/B on one commit showing the stack overflow lines without the PR and none with it (the runs so far were on Wine/vkd3d-proton, the "after" run also included #43, and the two runs in the comments took different paths); (2) whether the overflow happens on native Windows drivers at all.

CI: no check runs on the head commit.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/151#issuecomment-7148531964) <!-- victory-triage v1 head=d77408bb71e1822105ae8e88bbe942d8e5c39d1a verdict=needs-work at=2026-11-25T00:19:02Z --> Automated triage for the maintainers. **Needs work: needs the maintainer's decision.** This adds a new `apps/victory/build.rs` that passes `/STACK:16777216` to the linker for MSVC targets. Build scripts and linker settings are the maintainer's call. The change is small and only raises the reserve for threads created without an explicit size. What would help that decision: (1) an A/B on one commit showing the `stack overflow` lines without the PR and none with it (the runs so far were on Wine/vkd3d-proton, the "after" run also included #43, and the two runs in the comments took different paths); (2) whether the overflow happens on native Windows drivers at all. CI: no check runs on the head commit. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠larelgit on GitHub · 2026-11-25 14:55 UTC · original

A data point for question (2) in the triage, from native Windows. On my machine this change stops the title at startup, and I haven't seen the overflow it guards against.

Machine: RTX 5080 16 GB (driver 610.88), Ryzen 7 7800X3D, 32 GB, Windows 11 23H2, native D3D12, diagnostics builds.

With the 16 MiB reserve, the title stops on its own breakpoint 1 to 3 s after start in 12 of 12 runs, with every setting I tried. Those runs used the Belobug fork, which carries this commit: 10 at 4cbe9d7 and 2 at 01aadd1. The call just before the stop is the title's reservation of about 185 MB that has to lie below 4 GB (XMemVirtualAlloc with the 32-bit address flag), and it returns null.

A map of the address space below 4 GB at that moment shows why. Only 19 MB is free, the largest free block is 11 MB, and there are 37 reservations of exactly 16 MiB. Those are the stacks of threads created without a size, and that includes the title's own threads: by thread start address and stack reserve, 55 threads start in the title image, all at the executable's default. Builds without this change have 37 reservations of 1 MiB at the same point, and the call succeeds.

It is the reserve and not that fork's other changes:

  • Without this change: setting the header field of the same executable back to 1 MiB (editbin /STACK:1048576, nothing else changed) gets past this point in every run, 16 of 16.
  • With it on another tree: victory-fork's main (f85101b, Marvisak-based, without this commit) relinked at 16 MiB stops the same way at 1 s.
  • Sizes in between: 8 MiB (2 of 2), 4 MiB and 2 MiB (1 of 1 each) all get past it.

Stack overflows on native Windows at 1 MiB: there are 131 logs of VIctory-family builds on this machine, all with the linker's 1 MiB default. 98 of them logged for 290 s or more, through the world load, some with a cold shader cache. None has a stack overflow (0xC00000FD) or a stack overflow line.

On native Windows, then, the 16 MiB reserve takes low address space the title needs, and the case it fixes did not show up here. If the Wine case needs it, there are two ways to keep native Windows starting:

  • apply the bigger reserve only where it is needed;
  • use a reserve that still fits: 8 MiB got past here, though with less margin, and that depends on the machine's thread count.

Fuller report, including what happens after the start: Belobug/VIctory-Belobug-AMD#121.

(Runs and this note by Claude Code with Claude Opus 5.5, at the account owner's request. No title data.)

**@⁠larelgit** on GitHub · 2026-11-25 14:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/151#issuecomment-7166018196) A data point for question (2) in the triage, from native Windows. On my machine this change stops the title at startup, and I haven't seen the overflow it guards against. Machine: RTX 5080 16 GB (driver 610.88), Ryzen 7 7800X3D, 32 GB, Windows 11 23H2, native D3D12, diagnostics builds. **With the 16 MiB reserve**, the title stops on its own breakpoint 1 to 3 s after start in 12 of 12 runs, with every setting I tried. Those runs used the Belobug fork, which carries this commit: 10 at 4cbe9d7 and 2 at 01aadd1. The call just before the stop is the title's reservation of about 185 MB that has to lie below 4 GB (`XMemVirtualAlloc` with the 32-bit address flag), and it returns null. A map of the address space below 4 GB at that moment shows why. Only 19 MB is free, the largest free block is 11 MB, and there are 37 reservations of exactly 16 MiB. Those are the stacks of threads created without a size, and that includes the title's own threads: by thread start address and stack reserve, 55 threads start in the title image, all at the executable's default. Builds without this change have 37 reservations of 1 MiB at the same point, and the call succeeds. It is the reserve and not that fork's other changes: - **Without this change:** setting the header field of the same executable back to 1 MiB (`editbin /STACK:1048576`, nothing else changed) gets past this point in every run, 16 of 16. - **With it on another tree:** victory-fork's `main` (f85101b, Marvisak-based, without this commit) relinked at 16 MiB stops the same way at 1 s. - **Sizes in between:** 8 MiB (2 of 2), 4 MiB and 2 MiB (1 of 1 each) all get past it. **Stack overflows on native Windows at 1 MiB:** there are 131 logs of VIctory-family builds on this machine, all with the linker's 1 MiB default. 98 of them logged for 290 s or more, through the world load, some with a cold shader cache. None has a stack overflow (`0xC00000FD`) or a `stack overflow` line. On native Windows, then, the 16 MiB reserve takes low address space the title needs, and the case it fixes did not show up here. If the Wine case needs it, there are two ways to keep native Windows starting: - apply the bigger reserve only where it is needed; - use a reserve that still fits: 8 MiB got past here, though with less margin, and that depends on the machine's thread count. Fuller report, including what happens after the start: Belobug/VIctory-Belobug-AMD#121. (Runs and this note by Claude Code with Claude Opus 5.5, at the account owner's request. No title data.)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/151/head:github-bot/gh-151'
git switch 'github-bot/gh-151'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-151'
git switch 'github-bot/gh-151'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-151'
git switch 'github-bot/gh-151'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-151'
git switch 'main'
git merge --squash 'github-bot/gh-151'
git switch 'main'
git merge --ff-only 'github-bot/gh-151'
git switch 'main'
git merge 'github-bot/gh-151'
git push origin 'main'
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/Marvisak--VIctory!151
No description provided.