Tests: preserve GetLastError() in util::under_wine() #1135
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1135
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1135/head"
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?
@bigiello on GitHub · 2026-11-24 12:19 UTC · original
fix/util-under-wine-last-error→main· +42 −5 · 1 files · 1 commits · closed without mergingThe first call to
xcl::util::under_wine()callsGetProcAddress(ntdll, "wine_get_version"). On native Windows that export does not exist, soGetProcAddressfails and sets the calling thread's last error to127(ERROR_PROC_NOT_FOUND), clobbering any Win32 error the caller was about to inspect.Save and restore
GetLastError()around theGetModuleHandleA/GetProcAddressprobe sounder_wine()never mutates the calling thread's last error, even on its first invocation.Fixes #1125
What is in it
crates/xcl/src/util.rs:probe_under_wine()helper called byWINE.get_or_init(...)that savesGetLastError()before probingntdll.dllforwine_get_versionand restores it withSetLastError(saved).util::tests::under_wine_preserves_last_errorexercising both a coldunder_wine()call and directprobe_under_wine()calls across0,ERROR_ACCESS_DENIED, and a custom sentinel (0x1234_5678) so the test fails without the fix regardless of test order.Tested
Hardware: Windows 11 x64, AMD Ryzen 5 5600, 32 GB RAM, NVIDIA GeForce RTX 4070 SUPER (12 GB VRAM, D3D12 SM 6.6),
rustc 1.100.0(stable-x86_64-pc-windows-msvc), Windows SDK DXC1.8.2502.11, debug build. NoXCL_SAMPLE_*variables set.cargo test -p xcl --lib util::tests::under_wine_preserves_last_error -- --exact: 1 passed, 0 failed, 0 ignored (coldOnceLockinitialization + direct probe).cargo test -p xcl --lib util::tests: 6 passed, 0 failed, 0 ignored..\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 742 passed, 0 failed, 41 ignored, 2 GPU skipped (gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware:no wave64) —xcl --lib: 699 passed, 0 failed, 21 ignored; 15 integration test binaries: 43 passed, 0 failed, 20 ignored; bins and doc-tests: 0 passed, 0 failed.cargo test -p xcl --lib -- --test-threads=1: 699 passed, 0 failed, 21 ignored, 2 GPU skipped (no wave64).cargo test -p xcl --lib(default 12 threads, without--test-threads): process exited abnormally with0xc0000005(STATUS_ACCESS_VIOLATION) during parallel D3D12 tests (list_x::tests/readback_routing_tests, unrelated toutil.rs).cargo clippy --workspace --all-targets: 0 errors, 0 new warnings on the touched lines ofcrates/xcl/src/util.rs.rustfmt --edition 2021 --check crates/xcl/src/util.rs: 0 diffs on the modified lines (pre-existing diffs on untouched lines left alone perAGENTS.md).Not tested
scripts/smoke.ps1regression runs (no game files on this machine; Draft PR until a contributor with a title runs smoke or maintainers waive it).XCL_SAMPLE_*tests.AI use
Antigravity, Neon investigated #1125 and commit
d78597d, implemented theGetLastError()save/restore and unit test incrates/xcl/src/util.rs, ran the test/clippy/rustfmt checks above, and drafted this PR description.github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@JoaoPauluu on GitHub · 2026-11-24 13:45 UTC · original
The Wine side of this change.
Tested
x86_64-pc-windows-gnu.8da86a5as it is (based on47efa2e), no uncommitted changes. The lib test binary runs under Wine.util::tests::under_wine_preserves_last_error(--exact, one process): ok.ntdll.dllexportswine_get_version, so the probe'sGetProcAddresssucceeds and does not set the last error. This run therefore checks that the save and restore does no harm on Wine. It does not exercise the Windows failure from #1125, so it would pass without the fix too.Not tested
AI use
@upipibi on GitHub · 2026-11-24 14:06 UTC · original
This and #1128 (opened 9 minutes earlier) make the same change for #1125. Both save
GetLastError()around thewine_get_versionlookup and restore it, and both run the probe throughOnceLock::get_or_init. Their tests check the same two paths: the probe called directly, andunder_wine(). They differ only in names and comments, and they conflict inutil.rs, so CONTRIBUTING's one-of-several rule applies. Read from the diffs only; I have not run either.AI-assisted (Claude Code).
@Mischief8713 on GitHub · 2026-11-24 16:10 UTC · original
Native Windows run of
8da86a5(NVIDIA GTX 1660 Ti): the new test passes with the fix and fails without it, with 127 (ERROR_PROC_NOT_FOUND)Tested
cargo test -p xcl --lib util::tests::under_wine_preserves_last_erroron the head: 1 passed.SetLastError(saved);line inprobe_under_winedeleted: FAILED atutil.rs:491, left 127, right 305419896 (0x12345678).main; it was run as it is.Not tested
AI use
Pull request closed