xcl run: restore orig trampoline slot when RawDetour::enable fails #1558
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1568"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T17:45:53Z.
In
hooks::hook,orig.store(d.trampoline() as *const () as usize, Ordering::Release)ran befored.enable()?. Ifd.enable()failed,RawDetourdropped and freed the trampoline memory whileorigretained the dangling trampoline address.CString::new(func).unwrap()also panicked on interior NUL bytes.This extracts
enable_detour()to restore the previousorigvalue on error, and returnsErrinstead of panicking on invalid function names.What is in it
crates/xcl/src/hooks.rs: addenable_detour()rollback on failure, replaceCString::new(func).unwrap()withmap_err, and add unit testsenable_detour_restores_orig_on_failure_and_keeps_it_on_successandhook_rejects_interior_nul_without_panicking.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 778 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware; 1no heap windows—heap_window_out_of_memory_falls_back_to_the_switch_form)cargo test -p xcl --lib hooks::tests: 12 passed, 0 failed (includes the 2 newhooks::teststests)Regression run
main:
PR:
Not tested
AI use
hooks.rs, wrote the fix and unit tests, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T18:53:41Z.
Full-suite run, since this PR has no test report yet. Tested exact head
e33c721(on its base9e3831e).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 777 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.enable_detour_restores_orig_on_failure_and_keeps_it_on_success,hook_rejects_interior_nul_without_panicking.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 778 passed, 0 failed, 41 ignored. SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).heap_window_out_of_memory_falls_back_to_the_switch_formwas skipped with--skip. It fails on main9e3831etoo, not because of this PR: underXCL_REQUIRE_GPU=mesh,runner::skip_testturns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWSunset). Reported as #1651.Not tested
AI use
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T19:41:27Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.Thanks!
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T16:08:17Z.
NVIDIA test report for
e33c721: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug. Head tested as-is on its base9e3831e.cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4: 720 passed, 0 failed, 21 ignored; 2 SKIPPED (no wave64: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware), neither in a file this PR changes.hooks::tests::enable_detour_restores_orig_on_failure_and_keeps_it_on_successandhook_rejects_interior_nul_without_panicking, each with--exact --test-threads=1 --nocapture, 3 runs: 3/3 passed each, 0 SKIPPED.Lib tests only; no title run.
AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:34:58Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:08:46Z.
Triage (#1607) – head
e33c721No open or merged PR makes the same change. On an enable() failure
dis dropped, which frees the trampoline, so restoring the previous value oforigin hooks.rs:enable_detour is correct, and the new test covers both outcomes.The
CString::new(func).unwrap()-> error change is a second, unrelated fix that is not in the title; consider mentioning it in the description.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.