apps/victory: use dedicated Win32 HeapCreate global allocator and add VICTORY_NO_WATCH_GUARDS toggle #2424

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

@⁠faycalbaklouti on GitHub · 2026-11-25 13:14 UTC · original
faycalbaklouti:fix/win32-private-heap-allocator → main · +317 −0 · 4 files · 1 commits · open

Target upstream: Marvisak/VIctory (also applicable to Belobug/VIctory-Belobug-AMD and fxceless/victory-fork)

Problem

Sharing the default Win32 process heap (GetProcessHeap()) between the runtime's Rust allocator and title/Wine/system allocations can cause lock inversion deadlocks when a vectored exception handler (VEH) or hook runs while another thread holds the process heap lock. Additionally, having an explicit VICTORY_NO_WATCH_GUARDS diagnostic switch is useful when bisecting page-guard issues.

Solution

  • Add apps/victory/src/private_heap.rs implementing a #[global_allocator] backed by a dedicated Win32 HeapCreate heap so runtime allocations never contend with GetProcessHeap().
  • Wire it in apps/victory/src/main.rs and apps/victory/Cargo.toml.
  • Add the VICTORY_NO_WATCH_GUARDS toggle in crates/victory-gpu/src/watch.rs.

Verification

  • git apply --check passes cleanly on Marvisak/VIctory main (direct zero-conflict apply).

About our fork & censorship-resistant preservation effort:
This fix comes from gta6-vi-port, our open-source Linux (GE-Proton) + NVIDIA RTX 4090 fork of VIctory and peer-to-peer Radicle archival effort (mirroring 92+ community porting repositories across public Radicle seeds so open-source porting research survives centralized takedowns; open-source code only, no game files/keys/binaries).

**@⁠faycalbaklouti** on GitHub · 2026-11-25 13:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/2424) `faycalbaklouti:fix/win32-private-heap-allocator` → `main` · +317 −0 · 4 files · 1 commits · open **Target upstream:** `Marvisak/VIctory` (also applicable to `Belobug/VIctory-Belobug-AMD` and `fxceless/victory-fork`) ## Problem Sharing the default Win32 process heap (`GetProcessHeap()`) between the runtime's Rust allocator and title/Wine/system allocations can cause lock inversion deadlocks when a vectored exception handler (VEH) or hook runs while another thread holds the process heap lock. Additionally, having an explicit `VICTORY_NO_WATCH_GUARDS` diagnostic switch is useful when bisecting page-guard issues. ## Solution - Add `apps/victory/src/private_heap.rs` implementing a `#[global_allocator]` backed by a dedicated Win32 `HeapCreate` heap so runtime allocations never contend with `GetProcessHeap()`. - Wire it in `apps/victory/src/main.rs` and `apps/victory/Cargo.toml`. - Add the `VICTORY_NO_WATCH_GUARDS` toggle in `crates/victory-gpu/src/watch.rs`. ## Verification - `git apply --check` passes cleanly on `Marvisak/VIctory` `main` (direct zero-conflict apply). --- **About our fork & censorship-resistant preservation effort:** This fix comes from **[gta6-vi-port](https://github.com/go2afri/gta6-vi-port)**, our open-source Linux (GE-Proton) + NVIDIA RTX 4090 fork of VIctory and peer-to-peer Radicle archival effort (mirroring 92+ community porting repositories across public Radicle seeds so open-source porting research survives centralized takedowns; open-source code only, no game files/keys/binaries). - **Canonical Radicle repo:** https://radicle.network/nodes/rosa.radicle.network/rad:z39ofPhQC1siudH9BF3xsmAMmUqxc (`rad:z39ofPhQC1siudH9BF3xsmAMmUqxc`) - **Live 1080p development stream:** https://vdo.ninja/?view=gta6rtx4090live1080p60 (Tor v3 `.onion` VP9+Opus viewer: `http://kwnoaeecpmxd6eetqfa7fxlymvxnh5du2i6wxr44t4mc7cgch5pw23id.onion/`)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:05:23 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:32 UTC · original · edited 2026-11-25 16:05 UTC

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/watch.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (needs-work) was for an older state of main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/2424#issuecomment-7167001443) · edited 2026-11-25 16:05 UTC <!-- victory-triage v1 head=1954093b9effe0569973ef644bab9deae4276035 verdict=needs-rebase at=2026-11-25T16:04:40Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-gpu/src/watch.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (needs-work) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 16:54 UTC · original

Both halves check out:

Private heap — the over-alignment math is subtly right but worth the comment being explicit: size + align is only sufficient because HeapAlloc already returns 16-aligned blocks and HEADER_SIZE = 8, which bounds offset ≤ align (an unaligned base would need size + align + HEADER - 1). Lazy CAS init and the back-pointer scheme are sound; realloc correctly avoids HeapReAlloc for over-aligned blocks where the header would move.

VICTORY_NO_WATCH_GUARDS — early None from track matches the existing "untracked" path, so callers degrade the same way as runtime_memory misses. The trade-off is correctly scoped as an env toggle: writes stop being observed, so stale textures are the expected symptom while it sidesteps the AB-BA deadlock with GUARDS.

**@⁠kotekompotek** on GitHub · 2026-11-25 16:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2424#issuecomment-7168712984) Both halves check out: **Private heap** — the over-alignment math is subtly right but worth the comment being explicit: `size + align` is only sufficient because `HeapAlloc` already returns 16-aligned blocks and `HEADER_SIZE = 8`, which bounds `offset ≤ align` (an unaligned base would need `size + align + HEADER - 1`). Lazy CAS init and the back-pointer scheme are sound; realloc correctly avoids `HeapReAlloc` for over-aligned blocks where the header would move. **`VICTORY_NO_WATCH_GUARDS`** — early `None` from `track` matches the existing "untracked" path, so callers degrade the same way as `runtime_memory` misses. The trade-off is correctly scoped as an env toggle: writes stop being observed, so stale textures are the expected symptom while it sidesteps the AB-BA deadlock with `GUARDS`.
This pull request has changes conflicting with the target branch.
  • apps/victory/src/main.rs
  • crates/victory-gpu/src/watch.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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