Build: the high-entropy VA opt-out reaches only the xcl binary, so the 17 in-process integration tests run in the address space #631 removed #2263

Open
opened 2026-11-26 05:24:59 +00:00 by github-bot · 2 comments
Owner

@⁠itsonewi on GitHub · 2026-11-25 11:48 UTC · original

Summary

crates/xcl/build.rs (1a0bbe3) turns high-entropy VA off for one target:

Ok("msvc") => println!("cargo:rustc-link-arg-bin=xcl=/HIGHENTROPYVA:NO"),
Ok("gnu") => println!("cargo:rustc-link-arg-bin=xcl=-Wl,--disable-high-entropy-va"),

-bin=xcl is the [[bin]] xcl only. The crate also has a [lib], and 17 integration tests link that lib and drive the HLE in process:

pls_quota.rs  sparse_reinit.rs  texture_states.rs  gpu_compute_e2e.rs  predication_e2e.rs
d3d12_mesh_stream.rs  console_shaders.rs  xg_oracle.rs  gpu_pso_e2e.rs  d3d12_resource_and_sync.rs
console_dlls_e2e.rs  e2e.rs  heap_probe.rs  rpf_e2e.rs  disasm_e2e.rs  shaders_e2e.rs  launcher_e2e.rs

Those binaries are linked with Rust's default, so they keep high-entropy VA and their VirtualAlloc(NULL) reservations land around 1-2.5 TiB - the layout #631 measured and removed from xcl.exe:

default: first reservation at 0x1e1cb8a0000, 0x1eda2c40000 and 0x23344380000; 20/20 above 2^40 in every run
--disable-high-entropy-va: from 0x7fff0000 up; 0/20 above 2^40

(from #631's description)

Why it matters

heap_probe, sparse_reinit, pls_quota, predication_e2e and the rest run the HLE against an address space the released binary no longer has. Anything address-sensitive - the 2^40 ceiling in #585, the VirtualAlloc2 fallbacks @⁠sub-north traced, heap-window and sparse reservations - is exercised at 2 TiB in cargo test and at 2 GiB in xcl.exe. In both directions that is wrong: a test can pass over a path the exe cannot take, and can fail on a layout the exe cannot reach.

crates/xcl/tests/low_va.rs does not cover this: it reads env!("CARGO_BIN_EXE_xcl") (the binary's PE DllCharacteristics), so the process it runs in is still high-entropy VA.

Suggested fix

Ok("msvc") => {
    println!("cargo:rustc-link-arg-bin=xcl=/HIGHENTROPYVA:NO");
    println!("cargo:rustc-link-arg-tests=/HIGHENTROPYVA:NO");
}
Ok("gnu") => {
    println!("cargo:rustc-link-arg-bin=xcl=-Wl,--disable-high-entropy-va");
    println!("cargo:rustc-link-arg-tests=-Wl,--disable-high-entropy-va");
}

rustc-link-arg-tests applies to every integration-test binary of the package. The binary keeps its own directive, and the PE-header test keeps guarding it, so the two cannot drift apart silently. If the tests are meant to run in the default layout on purpose, then what is missing is a note saying so: as it stands the difference is invisible from the test side.

A cheap check after the change: a test that calls VirtualAlloc(NULL) once and asserts the returned address is below 2^40 - it fails on main today.

Not tested

  • Nothing run: read from 1a0bbe3 without a checkout, and the 1-2.5 TiB figures are #631's measurement, not a new one.

AI use

  • Claude (Opus 5.5) read crates/xcl/build.rs, crates/xcl/tests/low_va.rs and the list of tests that import the crate, and wrote this report; the human account checked each file before opening it.
**@⁠itsonewi** on GitHub · 2026-11-25 11:48 UTC · [original](https://github.com/xcl-dev/xcl/issues/2263) ### Summary `crates/xcl/build.rs` (`1a0bbe3`) turns high-entropy VA off for one target: ```rust Ok("msvc") => println!("cargo:rustc-link-arg-bin=xcl=/HIGHENTROPYVA:NO"), Ok("gnu") => println!("cargo:rustc-link-arg-bin=xcl=-Wl,--disable-high-entropy-va"), ``` `-bin=xcl` is the `[[bin]] xcl` only. The crate also has a `[lib]`, and 17 integration tests link that lib and drive the HLE in process: ``` pls_quota.rs sparse_reinit.rs texture_states.rs gpu_compute_e2e.rs predication_e2e.rs d3d12_mesh_stream.rs console_shaders.rs xg_oracle.rs gpu_pso_e2e.rs d3d12_resource_and_sync.rs console_dlls_e2e.rs e2e.rs heap_probe.rs rpf_e2e.rs disasm_e2e.rs shaders_e2e.rs launcher_e2e.rs ``` Those binaries are linked with Rust's default, so they keep high-entropy VA and their `VirtualAlloc(NULL)` reservations land around 1-2.5 TiB - the layout #631 measured and removed from `xcl.exe`: > default: first reservation at 0x1e1cb8a0000, 0x1eda2c40000 and 0x23344380000; 20/20 above 2^40 in every run > `--disable-high-entropy-va`: from 0x7fff0000 up; 0/20 above 2^40 (from #631's description) ### Why it matters `heap_probe`, `sparse_reinit`, `pls_quota`, `predication_e2e` and the rest run the HLE against an address space the released binary no longer has. Anything address-sensitive - the 2^40 ceiling in #585, the `VirtualAlloc2` fallbacks @⁠sub-north traced, heap-window and sparse reservations - is exercised at 2 TiB in `cargo test` and at 2 GiB in `xcl.exe`. In both directions that is wrong: a test can pass over a path the exe cannot take, and can fail on a layout the exe cannot reach. `crates/xcl/tests/low_va.rs` does not cover this: it reads `env!("CARGO_BIN_EXE_xcl")` (the binary's PE `DllCharacteristics`), so the process it runs in is still high-entropy VA. ### Suggested fix ```rust Ok("msvc") => { println!("cargo:rustc-link-arg-bin=xcl=/HIGHENTROPYVA:NO"); println!("cargo:rustc-link-arg-tests=/HIGHENTROPYVA:NO"); } Ok("gnu") => { println!("cargo:rustc-link-arg-bin=xcl=-Wl,--disable-high-entropy-va"); println!("cargo:rustc-link-arg-tests=-Wl,--disable-high-entropy-va"); } ``` `rustc-link-arg-tests` applies to every integration-test binary of the package. The binary keeps its own directive, and the PE-header test keeps guarding it, so the two cannot drift apart silently. If the tests are meant to run in the default layout on purpose, then what is missing is a note saying so: as it stands the difference is invisible from the test side. A cheap check after the change: a test that calls `VirtualAlloc(NULL)` once and asserts the returned address is below 2^40 - it fails on `main` today. **Not tested** - Nothing run: read from `1a0bbe3` without a checkout, and the 1-2.5 TiB figures are #631's measurement, not a new one. **AI use** - Claude (Opus 5.5) read `crates/xcl/build.rs`, `crates/xcl/tests/low_va.rs` and the list of tests that import the crate, and wrote this report; the human account checked each file before opening it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:24:59 +00:00
Author
Owner

@⁠Decodere on GitHub · 2026-11-25 12:19 UTC · original

Taking #2263 in crates/xcl/build.rs and crates/xcl/tests/low_va.rs.

Plan:

  • Emit cargo:rustc-link-arg-tests=/HIGHENTROPYVA:NO (MSVC) and cargo:rustc-link-arg-tests=-Wl,--disable-high-entropy-va (GNU) alongside the existing rustc-link-arg-bin=xcl directives in crates/xcl/build.rs.
  • Extend crates/xcl/tests/low_va.rs to check DllCharacteristics & HIGH_ENTROPY_VA == 0 on std::env::current_exe() as well as xcl.exe, plus verify a live VirtualAlloc(NULL, 64 KiB, MEM_RESERVE, PAGE_READWRITE) (freed with VirtualFree) lands below 1 << 40.
  • Verify failing-first on main, post-fix low_va pass, full cargo test --release --workspace across all 17 integration-test binaries under the low-VA layout, and pr_check.py.

AI use: drafted with Google Antigravity (Gemini 4 Neon); implementation and tests will run locally.

**@⁠Decodere** on GitHub · 2026-11-25 12:19 UTC · [original](https://github.com/xcl-dev/xcl/issues/2263#issuecomment-7162219772) Taking **#2263** in `crates/xcl/build.rs` and `crates/xcl/tests/low_va.rs`. **Plan:** - Emit `cargo:rustc-link-arg-tests=/HIGHENTROPYVA:NO` (MSVC) and `cargo:rustc-link-arg-tests=-Wl,--disable-high-entropy-va` (GNU) alongside the existing `rustc-link-arg-bin=xcl` directives in `crates/xcl/build.rs`. - Extend `crates/xcl/tests/low_va.rs` to check `DllCharacteristics & HIGH_ENTROPY_VA == 0` on `std::env::current_exe()` as well as `xcl.exe`, plus verify a live `VirtualAlloc(NULL, 64 KiB, MEM_RESERVE, PAGE_READWRITE)` (freed with `VirtualFree`) lands below `1 << 40`. - Verify failing-first on `main`, post-fix `low_va` pass, full `cargo test --release --workspace` across all 17 integration-test binaries under the low-VA layout, and `pr_check.py`. _AI use: drafted with Google Antigravity (Gemini 4 Neon); implementation and tests will run locally._
Author
Owner

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

Verified PR #2292 (\5a26eb9) on Windows 11 (NT \10.0.22631.0),
ustc 1.100.0\ MSVC, RTX 3060 (\XCL_ADAPTER=nvidia, debug profile):

  • \cargo test -p xcl --test low_va -- --nocapture: 2 passed, 0 failed, 0 ignored (\integration_tests_are_linked_without_high_entropy_va\ and \xcl_exe_is_linked_without_high_entropy_va).
  • \cargo test --workspace --no-fail-fast -- --test-threads=4: 1249 passed, 2 failed, 46 ignored (the 2 failures are pre-existing \GetCachedBlob()\ failures on this driver/setup, also present on \origin/main\ \
**@⁠Lum7nt** on GitHub · 2026-11-25 14:55 UTC · [original](https://github.com/xcl-dev/xcl/issues/2263#issuecomment-7166030316) Verified PR #2292 (\5a26eb9\) on Windows 11 (NT \10.0.22631.0\), \ ustc 1.100.0\ MSVC, RTX 3060 (\XCL_ADAPTER=nvidia\, debug profile): - \cargo test -p xcl --test low_va -- --nocapture\: **2 passed, 0 failed, 0 ignored** (\integration_tests_are_linked_without_high_entropy_va\ and \xcl_exe_is_linked_without_high_entropy_va\). - \cargo test --workspace --no-fail-fast -- --test-threads=4\: **1249 passed, 2 failed, 46 ignored** (the 2 failures are pre-existing \GetCachedBlob()\ failures on this driver/setup, also present on \origin/main\ \
This discussion has been locked. Commenting is limited to contributors.
No description provided.