Skip to content

EH: write final report on NtTerminateProcess under Wine (#1461) - #1479

Open
hajduzsolt wants to merge 2 commits into
xcl-dev:mainfrom
hajduzsolt:fix/wine-report-detach-fallback
Open

hajduzsolt wants to merge 2 commits into
xcl-dev:mainfrom
hajduzsolt:fix/wine-report-detach-fallback

Conversation

@hajduzsolt

@hajduzsolt hajduzsolt commented Nov 24, 2026 •

Copy link
Copy Markdown

Runtime fix verified with unit tests and RX 9070 XT smoke run.

What is in it

  • crates/xcl/src/eh.rs:
  • In hk_nt_terminate_process, checks crate::util::under_wine() and dispatches crate::report::write_final(None) before process termination and log flushing.
  • Adds synthetic unit test terminate_process_report_invocation_is_safe_under_wine verifying that write_final(None) executes safely without panics or deadlocks in test environments.

Tested

  • Hardware: AMD Radeon RX 9070 XT 16GB, AMD Ryzen 7 9800X3D, Windows 11 x64, rustc 1.98.1, debug
  • cargo test --workspace -- --test-threads=2: passed
  • cargo test -p xcl --lib eh::tests: 7 passed, 0 failed
  • cargo test -p xcl --lib report::tests: 1 passed, 0 failed

Regression run

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1594 (PresentX 1594)
presents per 2 s (last 3): 49 48 14
device removals: 0
crashes: 0
peak commit: 20195 MB

PR:

xcl-smoke v1
commit: 70364190b9f5256d3612dfcfd456c3807bbc76c5
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1682 (PresentX 1682)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14837 MB

Not tested

  • macOS CrossOver environments.

AI use

  • Antigravity (Gemini 4 Hydrogen, low) identified the Wine termination hook path, implemented the fallback dispatch, and authored the unit tests.

@Belox17

Belox17 commented Nov 24, 2026

Copy link
Copy Markdown

Test report for 9c400998 on Windows (RTX 3060 Ti): passes, but the new test also passes without the change

Tested

  • Ryzen 5 5600X, NVIDIA GeForce RTX 3060 Ti; Windows 11 build 26300; rustc 1.98.1 MSVC; debug build. PR head as is, clean tree.
  • cargo test --workspace -- --test-threads=4: 771 passed, 0 failed, 41 ignored (base b7aa9f3: 770). Merged into 9e3831e: 777 passed, 0 failed, 41 ignored.
  • With the five lines added to hk_nt_terminate_process removed (test kept), terminate_process_report_invocation_is_safe_under_wine still passes. It calls report::write_final(None) directly, which exists on main and returns at once when there is no boot state, so the new branch is never reached. On Windows, under_wine() is false, so nothing in the suite runs that branch.

For comparison, #1484 (same issue, #1461) moves this into on_nt_terminate(status, under_wine, write_final), and its test checks both branches with an injected write_final.

Not tested

  • Wine, which is the only place the change runs.

AI use: Claude Code (Claude Opus 5.5) ran the commands and wrote this report; I checked it before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

@SzczepanGrela

Copy link
Copy Markdown

Verified under real Wine (Linux / GE-Proton11-12, Wine Staging 11.0) against base b7aa9f3: PR head 9c40099 fixes #1461 for both clean (0) and non-zero (42) exits.

Setup. CachyOS, kernel 7.3.0-5-cachyos, AMD Radeon RX 9070 (RADV GFX1201, Mesa 26.2.5-arch3.1), GE-Proton11-12 (Wine Staging 11.0 + ntsync), vkd3d-proton v3.1-1-g8293130eb, DXC 1.9.2602.17. Built xcl.exe on base b7aa9f3 and PR 9c40099 with rustc 1.97.1 cross x86_64-pc-windows-gnu, release.

Test. Minimal synthetic console title (imports kernelx.dll!XclDefinitelyMissingFunction, calls it once, exits via ExitProcess(0) or ExitProcess(42)), run through xcl.exe run <dir> under Wine with XCL_NETWORK=0:

Exit path Base b7aa9f3 (report.json) PR #1479 9c40099 (report.json)
ExitProcess(0) exit_code: 0, called_stubs: [] exit_code: 0, called_stubs: [XclDefinitelyMissingFunction (1x)]
ExitProcess(42) exit_code: 42, called_stubs: [] exit_code: 42, called_stubs: [XclDefinitelyMissingFunction (1x)]

In both runs on 9c40099, the log shows report.json written inside hk_nt_terminate_process right before process ends (thread ...) with no crash and intact stack trace.

Not tested: full e2e test title (hits an unrelated Wine d3d11.dll 0x80000100 exception on this prefix), macOS CrossOver, or retail titles under Wine.

AI use: Antigravity (Gemini 4 Neon) cross-compiled b7aa9f3 and 9c40099, built the synthetic exit title, ran the Wine A/B checks on my machine, and drafted this report; I reviewed the results before posting.

@hajduzsolt
hajduzsolt marked this pull request as draft November 24, 2026 19:19
@hajduzsolt

Copy link
Copy Markdown
Author

Thank you for checking the test against the reverted change. The termination decision now accepts an injected report callback, and the regression covers Wine and native behavior, other-process handles, and repeated termination. cargo test --workspace -- --test-threads=2 passed (723 library tests passed, 21 ignored). Wine itself was not run in this revision.

@pablogonz12

Copy link
Copy Markdown
Contributor

Test report: #1479 at its current head 7036419, under Wine. e2e goes from failing on #1461 to passing.

The earlier real-Wine report was on 9c40099; this one covers the reworked head.

Setup

  • RX 9070 XT, Mesa 26.3.1 (RADV), Ryzen 9 9900X, kernel 7.3.6-1-cachyos, Wine Staging 11.0 (GE-Proton11-14), vkd3d-proton 3.1 + XCL's patch, DXC 1.9.2609.5.
  • rustc 1.100.0, cargo xwin, x86_64-pc-windows-msvc, release, +crt-static.

Method

e2e stops under Wine before it checks the report, so both sides carry the same three open PRs:

All merges were clean, and A and B differ only by this PR's eh.rs change. For the test title's Opus check I also put a locally built libopus opus.dll next to xcl.exe, on both sides.

Results

A B
e2e 2 passed, 1 failed: e2e.rs:164: report.called_stubs: [] (3 of 3 dedicated runs, and again in the integration pass) 3 passed, 0 failed (5 of 5 dedicated runs, and again in the integration pass)
xcl --lib, 4 threads 1090 passed, 6 failed, 26 ignored, 3 filtered out 1091 passed, 6 failed, 26 ignored, 3 filtered out
other integration binaries all pass except pls_quota, predication_e2e same
  • The six lib failures have the same names on both sides: fuzz_validate_and_gpu_2, directed_reference_basics, lower_dxil::tests::{f32,f64}_programs_on_the_gpu, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed. (directed_reference_basics comes from our +crt-static build: the static UCRT's fmaf is not correctly rounded.)
  • The extra pass in B is termination_reports_once_for_the_current_process_under_wine.
  • The 3 filtered tests are skipped because they end the whole test process on this host: integer_ops_match_cpu, uaddc_and_usubb_match_cpu, jumps_to_outer_loop_heads_are_structured.
  • Mutation: with only the write_report(); call in begin_termination removed, the new unit test fails (left: 0, right: 1). So the point raised on the earlier version, that its test also passed without the change, no longer applies.
  • From reading the code: a crash recorded earlier should survive the later write_final(None), because CRASH is filled with get_or_insert and None doesn't touch it. I did not run a crashing title.

Not tested: a retail title under Wine (so no Wine smoke pair), a nonzero or crash exit on this head, native Windows, and the suite on #1479 without the three other PRs.

AI use: Written with Claude (Anthropic) assistance; tested by me on the hardware listed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants