Loader: keep the cleared TLS callback pointer out of base relocations #4

Merged
Exorion1er merged 1 commit from upstream-pr/4 into main 2026-11-23 22:45:27 +00:00
Exorion1er commented 2026-11-23 22:37:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Exorion1er on 2026-11-23T22:37:38Z.


What

prepare() clears the TLS AddressOfCallBacks field but keeps its DIR64 base relocation. If the prepared copy is mapped anywhere but its preferred base, the relocation rewrites the 0 as the rebase delta, and the OS loader then walks a callback array at that bogus address.

On Windows this stays hidden because the copy gets 0x140000000. Under Wine/Proton, DYNAMIC_BASE DLLs are mapped high (here at 0x6ffff23c0000), so LoadLibraryExW faults inside ntdll before any title code runs.

The fix makes that relocation entry IMAGE_REL_BASED_ABSOLUTE (a no-op); patches_own_test_binary now asserts that no relocation targets the cleared field.

Tested

  • Fedora 44, GE-Proton11-12 (Wine 11.0), RX 9070 XT (RADV, Mesa 26.2.7), cross-built with xwin: before, a crash in ntdll during victory_loader::load; after, the title boots through the first-boot screens, the intro video with sound and the start menus (tested by hand).
  • cargo test -p victory-loader --lib under Wine: 6 passed.
  • Not run on Windows; there the copy loads at its preferred base, so the relocation changes nothing.

Note for Linux/Proton users (no code change)

Past the loader, vkd3d-proton caps shader-visible view heaps at 1,000,000 descriptors by default. GTA VI's heap is 1,245,184 (+65,536 dynamic), so VIctory falls back to the capped heap ("host view heap capped at 1000000") and the GPU page-faults on the first descriptor read past it. VKD3D_CONFIG=descriptor_heap (vkd3d-proton with VK_EXT_descriptor_heap, e.g. RADV on Mesa 26.2) lifts the cap, and the menus run at 30 fps.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6570266773 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/4). Originally posted by [Exorion1er](https://github.com/Exorion1er) on 2026-11-23T22:37:38Z. --- ## What `prepare()` clears the TLS `AddressOfCallBacks` field but keeps its DIR64 base relocation. If the prepared copy is mapped anywhere but its preferred base, the relocation rewrites the 0 as the rebase delta, and the OS loader then walks a callback array at that bogus address. On Windows this stays hidden because the copy gets 0x140000000. Under Wine/Proton, DYNAMIC_BASE DLLs are mapped high (here at 0x6ffff23c0000), so `LoadLibraryExW` faults inside ntdll before any title code runs. The fix makes that relocation entry `IMAGE_REL_BASED_ABSOLUTE` (a no-op); `patches_own_test_binary` now asserts that no relocation targets the cleared field. ## Tested - Fedora 44, GE-Proton11-12 (Wine 11.0), RX 9070 XT (RADV, Mesa 26.2.7), cross-built with xwin: before, a crash in ntdll during `victory_loader::load`; after, the title boots through the first-boot screens, the intro video with sound and the start menus (tested by hand). - `cargo test -p victory-loader --lib` under Wine: 6 passed. - Not run on Windows; there the copy loads at its preferred base, so the relocation changes nothing. ## Note for Linux/Proton users (no code change) Past the loader, vkd3d-proton caps shader-visible view heaps at 1,000,000 descriptors by default. GTA VI's heap is 1,245,184 (+65,536 dynamic), so VIctory falls back to the capped heap ("host view heap capped at 1000000") and the GPU page-faults on the first descriptor read past it. `VKD3D_CONFIG=descriptor_heap` (vkd3d-proton with `VK_EXT_descriptor_heap`, e.g. RADV on Mesa 26.2) lifts the cap, and the menus run at 30 fps. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:50:53 +00:00
Marvisak commented 2026-11-24 06:54:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-23T22:45:21Z.


Good catch, thanks for the PR

<!-- greyfinch-sync:Marvisak/VIctory:comment:7116142425 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/4#issuecomment-7116142425). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-23T22:45:21Z. --- Good catch, thanks for the PR
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!4
No description provided.