Repository navigation
fix(relinker): keep Windows startup stacks below the guest arena - #679
Merged
oneandonlydean merged 1 commit intoOct 5, 2026
Merged
oneandonlydean merged 1 commit into
oneandonlydean merged 1 commit into
Conversation
The PE writer marked relocatable executables HIGH_ENTROPY_VA. Windows then places the main thread stack, TEB, PEB and the loader threads' stacks, which exist before libc reserves the guest arena from 0x2_0000_0000, anywhere in the first TiB. Nearly half the time they land inside the arena and stay there as holes that fixed guest mappings cannot use. DllCharacteristics is now 0x140 (DYNAMIC_BASE, NX_COMPAT). The image is still relocated and bottom-up allocations keep the 8-bit randomization, but they start near the bottom of the address space, far below the arena. DLL placement does not depend on this flag. windows_address_space checks the flags and, on Windows, runs a relinked guest that returns the high dword of its stack pointer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Celegans12
force-pushed
the
fix/relinker-windows-low-entropy-stacks
branch
from
October 5, 2026 15:51
8b542bc to
823c3ca
Compare
12 tasks done
12 tasks done
This was referenced Nov 11, 2026
oneandonlydean
pushed a commit
that referenced
this pull request
Nov 13, 2026
With MinGW's default HIGH_ENTROPY_VA, Windows places the stacks of a test process's start-up threads anywhere from 4 GiB to past 1 TiB, so they sit inside the guest arena range in almost every run. Each is a 2 MiB reservation on a 2 MiB boundary, and when one lands on the AGC driver memory at 0xfe0000000, driver start-up fails with "replace guest placeholder with private memory: Attempt to access invalid address". #679 stopped writing HIGH_ENTROPY_VA into title executables for this reason, so link the test executables the same way: in add_test_executable, and for guest_video_out_wqhd_detection_exit_tests, the one test executable built outside it that loads libc. agc_driver_frame_replay_relaunch_tests no longer needs its own flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The relinked Windows executable is marked
HIGH_ENTROPY_VA(DllCharacteristics 0x160), so Windows places the main thread's stack, TEB, PEB and the loader threads' stacks anywhere in the first TiB before libc reserves the guest arena from 0x2_0000_0000. Nearly half the time they land inside it and stay as holes; a fixed guest mapping over one throwsfixed guest mapping overlaps a guest arena range.WindowsPeWriternow writes 0x140 (DYNAMIC_BASE,NX_COMPAT) for relocatable images; 0x100 without relocations is unchanged. The flag only lets ASLR use the whole 64-bit space (PE format, /HIGHENTROPYVA), and the process'sEnableHighEntropyASLR policy follows it.VirtualAllocwithout an address keep only the 8-bit bottom-up randomization instead of up to a TiB, starting near the bottom of the address space. The executable and the DLLs are still relocated into the 0x7ff… image range with either flag.Tested
-DBUILD_TESTING=ON, full build,--target libs,ctest:ctest --output-on-failure)windows_address_space: relinks theoptional_pltfixture with an entry returningrsp >> 32, checks DllCharacteristics 0x140 and, on Windows, runs it 8 times expecting the stack below 0x2_0000_0000. It fails onmain(0x160). In two series of 200 runs onmain, 195 put the stack in 0x2_0000_0000-0xFC_0000_0000 (81 and 95 below main's arena end 0x72_0000_0000); none do with this change.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)