XGameRuntime: avoid leaking Mount handles in mount_with_ui_async #1232

Open
b3IKK wants to merge 1 commit from upstream-pr/1242 into main
b3IKK commented 2026-11-24 13:39:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T13:39:51Z.


mount_with_ui_async called XPackageMount (allocating Box<Mount>) before begin_with validated the XAsyncBlock or scheduled work. If b was null (E_INVALIDARG) or its task queue was already terminated (E_ABORT), the allocated Mount handle was never returned to the caller and leaked permanently.

This copies the optional package identifier and performs XPackageMount inside the begin_with work closure so Mount is only allocated when the async work runs.

What is in it

  • crates/xcl/src/hle/xgameruntime/api.rs: move XPackageMount inside the begin_with work closure in mount_with_ui_async; add unit test mount_with_ui_async_does_not_leak_mount_on_invalid_or_aborted_call.
  • crates/xcl/src/hle/xgameruntime/mod.rs: add #[cfg(test)] LIVE_MOUNTS counter in XPackageMount / XPackageCloseMountHandle for the leak test.

This is now the only PR from this account that changes mount_with_ui_async: the mount part was taken out of #1610 (#1607, group D68), so the two do not compete for the same lines.

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (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): 994 passed, 0 failed, 45 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses, no heap windows, and cannot disable the driver cache (Windows Developer Mode is required))
  • cargo test -p xcl --lib -- mount_with_ui_async: 1 passed, 0 failed. With mount_with_ui_async put back to main's version and the test kept: 0 passed, 1 failed — Mount leaked on null XAsyncBlock.

Regression run

main (80f4819, clean tree, no local changes):

xcl-smoke v1
commit: 80f4819098e921f2e1ab371144d4832f68ffedd6
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1638 (PresentX 1638)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17779 MB

PR (7124d1e, clean tree, no local changes):

xcl-smoke v1
commit: 7124d1efab59ad2cadbecee8c95a356dfa6188b4
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1643 (PresentX 1643)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18020 MB

Not tested

  • a real title calling mount_with_ui_async with a terminated queue (the test builds that call)
  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Claude Fable 5.2: audited xgameruntime/api.rs, wrote the fix and the regression test (and confirmed it fails with the old function), rebased onto 80f4819, ran the test suite and the scripts/smoke.ps1 runs, and drafted this PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5473247111 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1242). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-24T13:39:51Z. --- `mount_with_ui_async` called `XPackageMount` (allocating `Box<Mount>`) before `begin_with` validated the `XAsyncBlock` or scheduled work. If `b` was null (`E_INVALIDARG`) or its task queue was already terminated (`E_ABORT`), the allocated `Mount` handle was never returned to the caller and leaked permanently. This copies the optional package identifier and performs `XPackageMount` inside the `begin_with` work closure so `Mount` is only allocated when the async work runs. **What is in it** - `crates/xcl/src/hle/xgameruntime/api.rs`: move `XPackageMount` inside the `begin_with` work closure in `mount_with_ui_async`; add unit test `mount_with_ui_async_does_not_leak_mount_on_invalid_or_aborted_call`. - `crates/xcl/src/hle/xgameruntime/mod.rs`: add `#[cfg(test)]` `LIVE_MOUNTS` counter in `XPackageMount` / `XPackageCloseMountHandle` for the leak test. This is now the only PR from this account that changes `mount_with_ui_async`: the mount part was taken out of #1610 (#1607, group D68), so the two do not compete for the same lines. **Tested** - hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (`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`): 994 passed, 0 failed, 45 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses, `no heap windows`, and `cannot disable the driver cache (Windows Developer Mode is required)`) - `cargo test -p xcl --lib -- mount_with_ui_async`: 1 passed, 0 failed. With `mount_with_ui_async` put back to `main`'s version and the test kept: 0 passed, 1 failed — `Mount leaked on null XAsyncBlock`. **Regression run** main (`80f4819`, clean tree, no local changes): ``` xcl-smoke v1 commit: 80f4819098e921f2e1ab371144d4832f68ffedd6 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1638 (PresentX 1638) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17779 MB ``` PR (`7124d1e`, clean tree, no local changes): ``` xcl-smoke v1 commit: 7124d1efab59ad2cadbecee8c95a356dfa6188b4 gpu: NVIDIA GeForce RTX 5080 title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1643 (PresentX 1643) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 18020 MB ``` **Not tested** - a real title calling `mount_with_ui_async` with a terminated queue (the test builds that call) - AMD GPUs and native wave64 hardware - other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine **AI use** - OpenCode, Claude Fable 5.2: audited `xgameruntime/api.rs`, wrote the fix and the regression test (and confirmed it fails with the old function), rebased onto `80f4819`, ran the test suite and the `scripts/smoke.ps1` runs, and drafted this PR description.
dcastell1 commented 2026-11-24 14:06:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T13:45:19Z.


Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@930e8b4 (baseline 751 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
752 passed; 0 failed; 41 ignored   (exit 0)

One more than the baseline; the XGameRuntime mount-handle leak fix is exercised and green.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

<!-- greyfinch-sync:ivall/xcl:comment:7133287903 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1242#issuecomment-7133287903). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T13:45:19Z. --- Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on `main@930e8b4` (baseline **751 passed, 0 failed, 41 ignored** on this box): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 752 passed; 0 failed; 41 ignored (exit 0) ``` One more than the baseline; the XGameRuntime mount-handle leak fix is exercised and green. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
DavidM1911 commented 2026-11-24 14:06:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T14:02:05Z.


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

  • cargo test -p xcl --lib lib xgameruntime: 74 passed, 0 failed.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7133729232 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1242#issuecomment-7133729232). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T14:02:05Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl --lib lib xgameruntime: 74 passed, 0 failed. Thanks!
b3IKK commented 2026-11-25 01:10:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-25T00:14:56Z.


Rebased onto 80f4819 (main had added a test at the same place in api.rs; both are kept) and re-ran: 994 passed, 0 failed, 45 ignored. This is now the only PR from this account that changes mount_with_ui_async: #1610 no longer does. Against main's function the test fails with Mount leaked on null XAsyncBlock. AI use: OpenCode, Claude Fable 5.2.

<!-- greyfinch-sync:ivall/xcl:comment:7148308693 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1242#issuecomment-7148308693). Originally posted by [b3IKK](https://github.com/b3IKK) on 2026-11-25T00:14:56Z. --- Rebased onto `80f4819` (`main` had added a test at the same place in `api.rs`; both are kept) and re-ran: 994 passed, 0 failed, 45 ignored. This is now the only PR from this account that changes `mount_with_ui_async`: #1610 no longer does. Against `main`'s function the test fails with `Mount leaked on null XAsyncBlock`. AI use: OpenCode, Claude Fable 5.2.
DavidM1911 commented 2026-11-26 05:05:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T04:32:26Z.


Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

<!-- greyfinch-sync:ivall/xcl:comment:7182683686 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1242#issuecomment-7182683686). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T04:32:26Z. --- Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
BBareth commented 2026-11-30 23:20:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T23:20:32Z.


merge-check claim
head: 7124d1efab

<!-- greyfinch-sync:ivall/xcl:comment:7295003020 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1242#issuecomment-7295003020). Originally posted by [BBareth](https://github.com/BBareth) on 2026-11-30T23:20:32Z. --- merge-check claim head: 7124d1efab59ad2cadbecee8c95a356dfa6188b4
BBareth commented 2026-11-30 23:28:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T23:28:27Z.


merge-check
base: d0832e614f
head: 7124d1efab
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, same run: 2890 passed, 0 failed, 51 ignored, 28 SKIPPED lines (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache). The new test mount_with_ui_async_does_not_leak_mount_on_invalid_or_aborted_call ran and passed.
review: no blocking finding; two files (+54/-7), every line read. mount_with_ui_async used to mount first and start the async operation second, so a refused start (null block) or a terminated queue left a Mount nobody could close; it now copies the identifier and mounts inside the operation's work closure. Two things to know, neither blocking: (1) an unknown package identifier is now reported through the async status (XAsyncGetStatus / the result call) instead of as the return value of the ...Async call itself; (2) a title that completes the operation and never fetches the result still leaves that mount open, as before this PR. The LIVE_MOUNTS counter exists only under #[cfg(test)]; it is process-wide, so a later test that mounts in parallel would disturb this one; I found no other direct call of XPackageMount in the crate today.
performance: none: the mount (one small allocation) moves from the caller's thread to the async work item.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.

<!-- greyfinch-sync:ivall/xcl:comment:7295158854 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1242#issuecomment-7295158854). Originally posted by [BBareth](https://github.com/BBareth) on 2026-11-30T23:28:27Z. --- merge-check base: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f head: 7124d1efab59ad2cadbecee8c95a356dfa6188b4 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, same run: 2890 passed, 0 failed, 51 ignored, 28 SKIPPED lines (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache). The new test `mount_with_ui_async_does_not_leak_mount_on_invalid_or_aborted_call` ran and passed. review: no blocking finding; two files (+54/-7), every line read. `mount_with_ui_async` used to mount first and start the async operation second, so a refused start (null block) or a terminated queue left a `Mount` nobody could close; it now copies the identifier and mounts inside the operation's work closure. Two things to know, neither blocking: (1) an unknown package identifier is now reported through the async status (`XAsyncGetStatus` / the result call) instead of as the return value of the `...Async` call itself; (2) a title that completes the operation and never fetches the result still leaves that mount open, as before this PR. The `LIVE_MOUNTS` counter exists only under `#[cfg(test)]`; it is process-wide, so a later test that mounts in parallel would disturb this one; I found no other direct call of `XPackageMount` in the crate today. performance: none: the mount (one small allocation) moves from the caller's thread to the async work item. verdict: safe to merge hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Foniass commented 2026-12-01 05:13:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:13:15Z.


Triage (#1607) – head 7124d1e

No open or merged PR makes the same change. #1610 (grouped with this one in #1607) changes QueryInterface identity and forwarding aliases in api.rs, unrelated to mount_with_ui_async.
Moving XPackageMount into the begin_with work closure means a null block or a terminated queue no longer leaks a Mount, and the id is copied so it outlives the call. The test's LIVE_MOUNTS counter is safe as long as no other test mounts in parallel (none does on main today).
#1247 also touches mount_with_ui_result next to this function; expect a textual conflict, not an overlap.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301542645 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1242#issuecomment-7301542645). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:13:15Z. --- **Triage (#1607)** – head 7124d1e No open or merged PR makes the same change. #1610 (grouped with this one in #1607) changes QueryInterface identity and forwarding aliases in api.rs, unrelated to `mount_with_ui_async`. Moving `XPackageMount` into the `begin_with` work closure means a null block or a terminated queue no longer leaks a `Mount`, and the id is copied so it outlives the call. The test's `LIVE_MOUNTS` counter is safe as long as no other test mounts in parallel (none does on main today). #1247 also touches `mount_with_ui_result` next to this function; expect a textual conflict, not an overlap. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
cj-tomlin commented 2026-12-02 17:13:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by cj-tomlin on 2026-12-02T17:13:26Z.


Test report, head 7124d1efab59ad2cadbecee8c95a356dfa6188b4 merged onto main 5eaadb54c14e0fc29597b2a1689d7dbd83491303 (clean, merge e9ac08f2).

  • Hardware: NVIDIA GeForce RTX 3080 10 GB, driver 621.40, AMD Ryzen 7 7800X3D, Windows 11 build 26300, debug build.
  • cargo build --workspace: ok.
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 2975 passed, 0 failed, 52 ignored; SKIPPED: 27 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll), the same 27 as plain main (2974 passed, 0 failed, 52 ignored) on this machine.
  • The new mount_with_ui_async_does_not_leak_mount_on_invalid_or_aborted_call passes, and fails with Mount leaked on null XAsyncBlock when I put main's mount_with_ui_async back into the merged tree.

Diff read (+54/-7, xgameruntime/api.rs, mod.rs), CPU only. Two behaviour changes beyond the leak, not blocking: an XPackageMount failure (e.g. E_NOT_FOUND for an unknown package) now comes back through XAsyncGetStatus instead of as the call's own return value, and an id that is not valid UTF-8 now reaches XPackageMount as null.

Tool and model: Claude Code (Claude Opus 5.5) merged, built, ran the tests and drafted this; I checked it.

<!-- greyfinch-sync:ivall/xcl:comment:7353068413 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1242#issuecomment-7353068413). Originally posted by [cj-tomlin](https://github.com/cj-tomlin) on 2026-12-02T17:13:26Z. --- Test report, head `7124d1efab59ad2cadbecee8c95a356dfa6188b4` merged onto `main` `5eaadb54c14e0fc29597b2a1689d7dbd83491303` (clean, merge `e9ac08f2`). - Hardware: NVIDIA GeForce RTX 3080 10 GB, driver 621.40, AMD Ryzen 7 7800X3D, Windows 11 build 26300, debug build. - `cargo build --workspace`: ok. - `cargo test --workspace --no-fail-fast -- --test-threads=4`: 2975 passed, 0 failed, 52 ignored; SKIPPED: 27 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll), the same 27 as plain `main` (2974 passed, 0 failed, 52 ignored) on this machine. - The new `mount_with_ui_async_does_not_leak_mount_on_invalid_or_aborted_call` passes, and fails with `Mount leaked on null XAsyncBlock` when I put `main`'s `mount_with_ui_async` back into the merged tree. Diff read (+54/-7, `xgameruntime/api.rs`, `mod.rs`), CPU only. Two behaviour changes beyond the leak, not blocking: an `XPackageMount` failure (e.g. `E_NOT_FOUND` for an unknown package) now comes back through `XAsyncGetStatus` instead of as the call's own return value, and an id that is not valid UTF-8 now reaches `XPackageMount` as null. Tool and model: Claude Code (Claude Opus 5.5) merged, built, ran the tests and drafted this; I checked it.
Pipodi commented 2026-12-02 22:08:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Pipodi on 2026-12-02T22:08:55Z.


merge-check
base: 5ad98adbc3
head: 7124d1efab
merge: clean (git merge --no-ff onto 5ad98adb, merge d54cc037; xgameruntime/api.rs +47/-7, xgameruntime/mod.rs +7)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3006 passed, 0 failed, 52 ignored; failing: none (SKIPPED 25: 22 no wave64, 2 no heap windows, 1 cannot disable the driver cache). The new xgameruntime::api::tests::mount_with_ui_async_does_not_leak_mount_on_invalid_or_aborted_call passes.
title run: retail title on NVIDIA GeForce RTX 4090, no save, into the in-engine intro cutscenes: 376 s in the cutscenes (log 58-434 s, from the first 2 s window with cutscene draws to the end), 0 device removals, 0 crashes (exit 0x0, ended by XCL_RUN_SECONDS=420), 3.86 presents/s in the cutscenes (1452 presents in 376 s, from the log's 2 s activity lines; 2559 presents in the run), peak private 43.4 GB. Same env and frame presses on main 5ad98adb tonight: run 1 388 s in the cutscenes, 4.83 presents/s, 0 removals, exit 0x0, 2544 presents; run 2 device hung (0x887a0006) at 297.8 s after 238 s in the cutscenes at 4.64 presents/s, so main itself does not always get through. The title logs no XPackageMount line, so this run does not show whether it calls XPackageMountWithUiAsync at all: it checks for regressions, not the fix. Title binary = merge result + local scripted-press commits (input only) and two local log-only diagnostics, the same stack as the main runs.
review: read the whole diff, begin_with/payload_provider (xasync.rs) and XPackageMount. No blocking findings. 1) The fix is right: XPackageMount now runs inside the work closure, so a null XAsyncBlock or a terminated queue (where XAsyncBegin fails and begin_with_fixups frees the payload) no longer leaves a boxed Mount behind; the id is copied into an owned NUL-terminated buffer before the call, so the work no longer depends on the caller's string staying alive. 2) Behaviour change, as the earlier test report noted: an XPackageMount failure (E_NOT_FOUND for another package id) now comes back through XAsyncGetStatus/the result call instead of from XPackageMountWithUiAsync itself; that is the normal async pattern for this GDK API (XPackageMountWithUiAsync / XPackageMountWithUiResult in the GDK 261000 XPackage.h), so fine. 3) Not covered (and not made worse): a mount that completes but whose result the title never reads still keeps its Mount until the process ends. 4) LIVE_MOUNTS is test-only and global; no other test calls XPackageMount, so it does not race today, but a future test that mounts in parallel would make this one flaky.
performance: none: one heap copy of the package id per call of a function a title calls once or twice; nothing on a per-frame path. Cutscene presents/s 3.86 vs 4.83 and 4.64 on main: the spread between runs of the same build is this large here (main run 2 device-hung, the other PR's runs tonight 4.24-4.82), and this diff does not run per frame; peak private 43.4 vs 43.5 GB.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4090 24 GB, driver 621.40; Intel Core i9-13900K, 32 GB; Windows 11 build 26300; rustc 1.100.0, debug (tests) / release (title run); Claude Code, Claude Opus 5.5

<!-- greyfinch-sync:ivall/xcl:comment:7360290459 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1242#issuecomment-7360290459). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-12-02T22:08:55Z. --- merge-check base: 5ad98adbc360225ac8a57ad9661e16fe8df9d8dd head: 7124d1efab59ad2cadbecee8c95a356dfa6188b4 merge: clean (`git merge --no-ff` onto 5ad98adb, merge d54cc037; xgameruntime/api.rs +47/-7, xgameruntime/mod.rs +7) build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3006 passed, 0 failed, 52 ignored; failing: none (SKIPPED 25: 22 no wave64, 2 no heap windows, 1 cannot disable the driver cache). The new xgameruntime::api::tests::mount_with_ui_async_does_not_leak_mount_on_invalid_or_aborted_call passes. title run: retail title on NVIDIA GeForce RTX 4090, no save, into the in-engine intro cutscenes: 376 s in the cutscenes (log 58-434 s, from the first 2 s window with cutscene draws to the end), 0 device removals, 0 crashes (exit 0x0, ended by XCL_RUN_SECONDS=420), 3.86 presents/s in the cutscenes (1452 presents in 376 s, from the log's 2 s activity lines; 2559 presents in the run), peak private 43.4 GB. Same env and frame presses on main 5ad98adb tonight: run 1 388 s in the cutscenes, 4.83 presents/s, 0 removals, exit 0x0, 2544 presents; run 2 device hung (0x887a0006) at 297.8 s after 238 s in the cutscenes at 4.64 presents/s, so main itself does not always get through. The title logs no XPackageMount line, so this run does not show whether it calls XPackageMountWithUiAsync at all: it checks for regressions, not the fix. Title binary = merge result + local scripted-press commits (input only) and two local log-only diagnostics, the same stack as the main runs. review: read the whole diff, `begin_with`/`payload_provider` (xasync.rs) and `XPackageMount`. No blocking findings. 1) The fix is right: `XPackageMount` now runs inside the work closure, so a null `XAsyncBlock` or a terminated queue (where `XAsyncBegin` fails and `begin_with_fixups` frees the payload) no longer leaves a boxed `Mount` behind; the id is copied into an owned NUL-terminated buffer before the call, so the work no longer depends on the caller's string staying alive. 2) Behaviour change, as the earlier test report noted: an `XPackageMount` failure (`E_NOT_FOUND` for another package id) now comes back through `XAsyncGetStatus`/the result call instead of from `XPackageMountWithUiAsync` itself; that is the normal async pattern for this GDK API (`XPackageMountWithUiAsync` / `XPackageMountWithUiResult` in the GDK 261000 XPackage.h), so fine. 3) Not covered (and not made worse): a mount that completes but whose result the title never reads still keeps its `Mount` until the process ends. 4) `LIVE_MOUNTS` is test-only and global; no other test calls `XPackageMount`, so it does not race today, but a future test that mounts in parallel would make this one flaky. performance: none: one heap copy of the package id per call of a function a title calls once or twice; nothing on a per-frame path. Cutscene presents/s 3.86 vs 4.83 and 4.64 on main: the spread between runs of the same build is this large here (main run 2 device-hung, the other PR's runs tonight 4.24-4.82), and this diff does not run per frame; peak private 43.4 vs 43.5 GB. verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 4090 24 GB, driver 621.40; Intel Core i9-13900K, 32 GB; Windows 11 build 26300; rustc 1.100.0, debug (tests) / release (title run); Claude Code, Claude Opus 5.5
vasanex commented 2026-12-03 03:21:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T03:21:59Z.

Review: COMMENTED


Review of 7124d1ef (code reading and the tests named below, not a merge-check) · no findings

In short: the mount now happens inside the async work, so a call that never starts (null block) or whose queue is already terminated no longer leaves a Mount behind. The identifier is copied before the call returns, so the work does not read the title's string later. begin_with drops the payload, and with it the copied identifier, when XAsyncBegin refuses the call.

Result: no blockers found. From the code, nothing stands in the way of a merge. This is a review, not a merge-check: the suite and a title run are not covered here.

Measured (RTX 3080, Ryzen 9 7950X, merge of this head onto main 395405e4, debug)

  • cargo test -p xcl --lib -- mount_with_ui_async_does_not_leak xgameruntime: 87 passed, 0 failed.
  • With main's body of mount_with_ui_async put back, mount_with_ui_async_does_not_leak_mount_on_invalid_or_aborted_call fails ("Mount leaked on null XAsyncBlock", 1 live), so the test pins the fix.

Note, not blocking: a mount that fails (an unknown package, E_NOT_FOUND) used to fail the ...Async call itself; it now returns S_OK there and the error comes out of XAsyncGetStatus / the result call. That is the usual shape of an async operation, but it is a change a title can see, and a line in the description would record it.

Not checked: the whole suite and a title run on this head; a title that calls this function.

Review by Claude Code (Claude Fable 5.2), posted without a human check of each point. An automated PR review workflow is running at the request of the user.

<!-- greyfinch-sync:ivall/xcl:review:6163167889 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1242#pullrequestreview-6163167889). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T03:21:59Z. **Review:** COMMENTED --- **Review** of `7124d1ef` (code reading and the tests named below, not a merge-check) · no findings **In short:** the mount now happens inside the async work, so a call that never starts (null block) or whose queue is already terminated no longer leaves a `Mount` behind. The identifier is copied before the call returns, so the work does not read the title's string later. `begin_with` drops the payload, and with it the copied identifier, when `XAsyncBegin` refuses the call. **Result:** no blockers found. From the code, nothing stands in the way of a merge. This is a review, not a merge-check: the suite and a title run are not covered here. **Measured** (RTX 3080, Ryzen 9 7950X, merge of this head onto `main` `395405e4`, debug) - `cargo test -p xcl --lib -- mount_with_ui_async_does_not_leak xgameruntime`: 87 passed, 0 failed. - With `main`'s body of `mount_with_ui_async` put back, `mount_with_ui_async_does_not_leak_mount_on_invalid_or_aborted_call` fails ("Mount leaked on null XAsyncBlock", 1 live), so the test pins the fix. **Note, not blocking:** a mount that fails (an unknown package, `E_NOT_FOUND`) used to fail the `...Async` call itself; it now returns `S_OK` there and the error comes out of `XAsyncGetStatus` / the result call. That is the usual shape of an async operation, but it is a change a title can see, and a line in the description would record it. **Not checked:** the whole suite and a title run on this head; a title that calls this function. Review by Claude Code (Claude Fable 5.2), posted without a human check of each point. An automated PR review workflow is running at the request of the user.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1242:upstream-pr/1242'
git switch 'upstream-pr/1242'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/1242'
git switch 'upstream-pr/1242'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1242'
git switch 'upstream-pr/1242'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1242'
git switch 'main'
git merge --squash 'upstream-pr/1242'
git switch 'main'
git merge --ff-only 'upstream-pr/1242'
git switch 'main'
git merge 'upstream-pr/1242'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1232
No description provided.