Repository navigation
fix(shutdown): join GameUI workers before unloading - #6
Merged
Merged
Conversation
Co-Authored-By: Codex <codex@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GameUI can terminate its socket worker from its DLL destructor while that worker owns a UCRT lock. On real HL 3266 this leaves the engine network worker blocked in normal thread cleanup, with the main thread waiting for it indefinitely.
This change joins GameUI's managed threads before the engine calls FreeLibrary, outside the loader and socket locks. The engine FreeLibrary hook now covers PE and BLOB engines across hl-, svencoop- and cof-*. Existing ServerBrowser pre-unload waiting, engine-state gates and callback-only module exclusions remain intact.
GameUI/ServerBrowser select waits are capped at 20 ms. Once termination starts, select reports no readiness and recvfrom returns WSAEWOULDBLOCK, allowing continuous nonblocking receive loops to unlock and reach their existing shutdown-event check. Both Winsock import DLL names are supported; main-thread socket calls and socket timeout options remain unchanged.
Validation:
Known validation limit: repeated HL 3266 runs also encountered heap corruption during reload and an allocator shutdown spin after both generations' network joins completed. These failures remain unresolved, so this PR does not claim consistently successful full-installation restarts. Teardown diagnostics remain debugger output because the GameUI console may already be shut down.
Follow-up to #4 and #5. Companion fixture documentation: MetaHookSv/MetaHook#5 (binary/source correspondence and remaining failures).