XGameRuntime: null out-pointers on result retrieval and lookup failures #1247
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!1247
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1247"
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?
@mahfuzinam0045-spec on GitHub · 2026-11-24 13:42 UTC · original
mahfuzinam0045-spec:fix/xgameruntime-null-outptr-on-failure→main· +124 −5 · 4 files · 2 commits · openUnder standard Win32, COM, and GDK conventions (
_COM_Outptr_,_Outptr_result_maybenull_, etc.), functions that produce output pointers or handles must set non-null out-pointer parameters to null (std::ptr::null_mut()) whenever the function fails or returns an error HRESULT.Previously, several asynchronous result retrieval functions (
XUserGetTokenAndSignatureResult,XUserGetTokenAndSignatureUtf16Result,XUserAddResult,XGameSaveInitializeProviderResult,install_chunks_result,mount_with_ui_result) and handle/object lookup functions (XUserFindUserByLocalId,XUserFindUserById,XUserDuplicateHandle,XPackageMount,XGameSaveCreateContainer,XGameSaveCreateUpdate,XTaskQueue*) left output pointers uninitialized on error. Callers that check the pointer after failure or have cleanup paths (e.g.if (ptr) ptr->Release()) can dereference uninitialized stack/heap memory or trigger access violations (as seen when auth token or live requests fail offline).This aligns these functions with existing implementations like
XNetworkingQuerySecurityInformationForUrlUtf16AsyncResult,XStoreCreateContext, andquery_interfacewhich already properly null out-pointers.What is in it
crates/xcl/src/hle/xgameruntime/mod.rs: initialize*ptr_to_buffer = std::ptr::null_mut()onXUserGetTokenAndSignatureResultandXUserGetTokenAndSignatureUtf16Result; null*outinXUserAddResult,XUserDuplicateHandle,XUserFindUserByLocalId,XUserFindUserById, andXPackageMount.crates/xcl/src/hle/xgameruntime/gamesave.rs: initialize*out = std::ptr::null_mut()onXGameSaveInitializeProviderResult,XGameSaveCreateContainer, andXGameSaveCreateUpdate.crates/xcl/src/hle/xgameruntime/taskqueue.rs: initialize*out = std::ptr::null_mut()onXTaskQueueCreate,XTaskQueueGetPort,XTaskQueueCreateComposite, andXTaskQueueDuplicateHandle.crates/xcl/src/hle/xgameruntime/api.rs: checkout.is_null()and set*out = 0oninstall_chunks_resultandmount_with_ui_result.mod.rs,gamesave.rs, andtaskqueue.rsverifying that on error, out-pointers pre-populated with non-null canary values (0xDEADBEEF) are properly nulled tostd::ptr::null_mut().Tested
crates/xcl/src/hle/xgameruntime/mod.rs(result_and_lookup_functions_null_outptrs_on_failure),gamesave.rs(gamesave_functions_null_outptrs_on_failure), andtaskqueue.rs(taskqueue_functions_null_outptrs_on_failure) asserting that out-pointers are consistently set tonull_mut()on error.Regression run
test-onlylabel waiver.Not tested
AI use
@Anon64 on GitHub · 2026-11-24 13:51 UTC · original
Regression run for this PR: head
bc44eee, based onmain47efa2e. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s.main
47efa2e:this PR:
No device removals or crashes; 95 % of main's frames, 103 % of its peak commit.
Not tested: the whole suite; the PR's new tests; whether the title hits these failure paths in 60 s.
Written with Claude Code (Claude Opus 5.5) from runs on this machine.
@DavidM1911 on GitHub · 2026-11-24 13:59 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib xgameruntime: 75 passed, 1 failed — the PR's own new test fails deterministically:One of the result-retrieval paths returns S_OK (0) where the test expects E_INVALIDARG (0x80070057) — the null out-pointer isn't being rejected on that path. Everything else in the area passes.
@mahfuzinam0045-spec on GitHub · 2026-11-24 16:31 UTC · original
Thank you @DavidM1911 and @Anon64!
We traced why
XTaskQueueGetPort(std::ptr::null_mut(), ...)returnedS_OK: in GDK and XCL's implementation, passingnullreferences the valid default process task queue (queue_from(queue)delegates toprocess_queue()).In commit
c0530cc, we updated the test assertion to pass an invalid non-null handle (0x1234 as *mut c_void) and an out-of-range port index (99). Both error paths returnE_INVALIDARGas expected and verify that the out-pointers are nulled tostd::ptr::null_mut().All unit tests in
crates/xcl/src/hle/xgameruntime/taskqueue.rsnow pass cleanly.@Toons29 on GitHub · 2026-11-25 03:18 UTC · original
Regression run of
c0530ccbon the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 100 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.@DavidM1911 on GitHub · 2026-11-26 04:32 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.