HLE: preserve ERROR_TLW_WITH_WSCHILD and close relaunch duplicate handle #3317
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3317"
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 Marvisak/VIctory. Originally posted by mgunes1311-lab on 2026-11-26T17:20:01Z.
Coordination
Claimed in https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7197202703 (
HLE: preserve Win32 ERROR_TLW_WITH_WSCHILD on null-parent WS_CHILD windows and close duplicated handle in lifecycle::relaunch). CheckedSTATUS.md,CLAIMS.md, andforge/main— zero overlapping PRs or diff incrates/victory-hle/src/modules/lifecycle.rs.Problem
Two Win32 lifecycle edge cases in
crates/victory-hle/src/modules/lifecycle.rs:CreateWindowExWandCreateWindowExAcheckedlet top = parent.is_null();without checkingWS_CHILD. When a caller passedstyle = WS_CHILDwithparent = NULL, substitutingHWND_MESSAGEcaused Win32 to create a message-only child window and attempt a stand-in window withWS_CHILD(parent = NULL, logging a spurious warning) instead of failing withNULLandERROR_TLW_WITH_WSCHILD(1406).relaunchduplicated the current process handle withbInheritHandle = TRUE(DuplicateHandle) forVICTORY_RELAUNCHED_FROM, but never calledCloseHandle(me)in the parent aftercommand.spawn()returned (OkorErr), leaking an inheritable self-process handle on failed or repeated relaunch attempts.Fix
let top = parent.is_null() && style & wm::WS_CHILD == 0;in bothCreateWindowExWandCreateWindowExA.relaunch_exeand callCloseHandle(me)immediately aftercommand.spawn()returns, onceCreateProcessWhas inherited the handle into the child (or failed).Verification
null_parent_ws_child_windows_fail_with_win32_error_while_valid_children_succeedtesting bothCreateWindowExWandCreateWindowExAwithWS_CHILD+ null parent (NULL+ERROR_TLW_WITH_WSCHILD) and valid parent (GetParent == parent, hooked procedure, no stand-in).relaunch_closes_its_duplicated_process_handleverifying process handle count stability across 257 failed spawns and a successfulComSpec /C exit 0child launch.cargo test -p victory-hle --locked modules::lifecycle::tests::(14/14 passed),cargo clippy --workspace --all-targets --all-features --locked -- -D warnings, andcargo xtask policyon Windows 11 (x86_64-pc-windows-msvc).AI-assisted contribution (Google Antigravity); all code and Win32 unit tests were locally executed and verified.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T17:27:22Z.
Review: APPROVED
Reviewed the diff and verified locally on Windows 11 x64:
parent.is_null() && style & wm::WS_CHILD == 0preserves Win32ERROR_TLW_WITH_WSCHILDinstead of turning invalidWS_CHILDwindows into message-only windows, and closing the duplicated process handle inrelaunch_exeafterspawn()prevents handle leaks.cargo test -p victory-hle --lib modules::lifecycle:: -- --test-threads=1: 14 passed, 0 failed (includingnull_parent_ws_child_windows_fail_with_win32_error_while_valid_children_succeedandrelaunch_closes_its_duplicated_process_handle).cargo clippy -p victory-hle --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:44:12Z.
Windows 11,
63bcca4+ this PR:cargo test -p victory-hle lifecycle::: 14 passed / 0 failed.cargo clippy -p victory-hle --all-targets -- -D warnings: clean.The two new tests are in that 14:
null_parent_ws_child_windows_fail_with_win32_error_while_valid_children_succeedandrelaunch_closes_its_duplicated_process_handle, so the Win32 error path and the duplicated-handle close are exercised on the real OS. Synthetic only. AI-assisted.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.