Skip to content

fix(shutdown): join engine workers after runtime state resets - #7

Merged
hzqst merged 1 commit into
mainfrom
fix/engine-exit-worker-join
Oct 6, 2026
Merged

hzqst merged 1 commit into
mainfrom
fix/engine-exit-worker-join

Conversation

@hzqst

@hzqst hzqst commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

HL 3266 resets CEngine::GetState() to DLL_INACTIVE before the launcher calls ExitGame. ThreadGuard's close/restart gate then skipped its general engine-worker join, allowing old Steam discovery workers to outlive the engine heap during _restart. A captured worker faulted while returning invalid WSABUF storage to the small-block allocator, leaving its lock held; later CRT cleanup looped in Sleep(128).

Use the ExitGame lifecycle boundary to always request and join the engine manager before CRT detach. Keep the earlier GameUI/ServerBrowser unload gates and NET_Shutdown ordering. Add a real-worker regression covering inactive, close, restart and active states, absent engine/manager, and repeated calls; update both READMEs and repository guidance.

Validation:

  • The new regression failed on the original inactive-state path; Debug/Release builds and both CTests pass with the fix.
  • Original HL 3266 fixture: five de_dust2 -> _restart -> quit runs exited 0 without the previously captured access violations or heap-corruption exception. No debugger state override was used.
  • HL 10210 and CoF 5936 startup/quit, and Sven 10257 osprey -> _restart -> quit, exited 0.
  • All 11 gamedata snapshots validate; the other seven snapshots were not individually launched.
  • Temporary game files were restored and compared with their backups; git diff --check passes.

The separately observed earlier 0xc0000374 reload crash is not independently proven to have this cause. This change does not claim to resolve every HL 3266 restart failure.

Real-fixture investigation and verification record: MetaHookSv/MetaHook#6.

@hzqst
hzqst merged commit 1b6b59e into main Oct 6, 2026
1 check passed
@hzqst
hzqst deleted the fix/engine-exit-worker-join branch October 6, 2026 16:33
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.

1 participant