HLE: preserve ERROR_TLW_WITH_WSCHILD and close relaunch duplicate handle #3317
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3317
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@mgunes1311-lab on GitHub · 2026-11-26 17:20 UTC · original
mgunes1311-lab:hle-lifecycle-child-relaunch→main· +176 −14 · 1 files · 1 commits · openCoordination
Claimed in #1633 (
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.
@Dukestar69 on GitHub · 2026-11-26 17:27 UTC · original · approved these changes
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).
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.