Keep the title's thread_local exit callback out of the host CRT #488
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/488"
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 TaynanGT/Vice-Tay. Originally posted by SmartIngenieriayDesarrollo on 2026-12-01T03:02:10Z.
What
The title's CRT runs as if it were the process's exe. At start it calls
_register_thread_local_exe_atexit_callback(imported fromapi-ms-win-crt-runtime-l1-1-0.dll) to register the destructor of itsthread_locals.The host UCRT accepts one such callback per process and calls
terminate()on a second one.victory.exeregisters its own callback as soon as it links any C++ code withthread_locals. The title's call is then the second one, and the start aborts with0xC0000409(FAST_FAIL_FATAL_APP_EXITinucrtbase!abort).We hit this when we linked the Tracy client (
tracing-tracy/tracy-client). The same would happen with any other C++ dependency that hasthread_locals.This PR resolves that import to our own function in
modules/kernel.rs. The function:atexit;callback(NULL, DLL_PROCESS_DETACH, NULL), which is what the UCRT does incommon_exit.Builds without C++
thread_locals see no difference. The title's callback still runs at exit, now from the exit table instead of the UCRT's single slot.Prior art
at_quick_exithandlers the runtime's own.How it was found
cdb, breakpoint onucrtbase!register_thread_local_exe_atexit_callback:tracyfeaturevictory!__scrt_common_main_seh, then the title's CRT (called from the loader)victory!__scrt_common_main_sehonlyTests
main(0d692a31), with the one-line test fix of #487 applied (apu.rs, needed forcargo test -p victory-hleto compile):cargo test -p victory-hle --lib: 424 passed, 1 failed. The failure isxmem::tests::a_read_by_range_waits_only_for_a_remapping_that_meets_it, which passes when run alone, 3 times out of 3, also onmainwithout this change: it is timing-sensitive under the full parallel run.New
title_tls_exit_callback_is_kept_not_passed_to_the_hostchecks that:DLL_PROCESS_DETACH.Tested on: Windows 11, Ryzen 7 5700X3D, RX 7800 XT, Series S 1.0.2.1. A release build with the Tracy client linked now starts and reaches the prison cell, where it previously died at 1.5 s.
— El_Santo
AI-assisted: yes
Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-12-01T03:02:19Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
dedbdb4ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-12-01T03:11:49Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
dedbdb4b92ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-12-01T03:11:49Z.
Code review location:
docs/tests.md; line 19When this section is used to validate a change, the Series S launch and once-a-second summaries cannot establish the acceptance conditions in
AGENTS.md: Series X, 3840×2160 with RT, a bracketed controllable-boat route, and individual frame intervals with counts above 50/30/15 ms. Filtering summaries by draw count can include cinematics and cannot reveal individual stalls or produce the required frame-based 1% low. Document the canonical per-present trace procedure and label the Series S sessions as historical, non-acceptance measurements.AGENTS.md reference: AGENTS.md:L51-L54
Useful? React with 👍 / 👎.
Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-12-01T03:11:49Z.
Code review location:
README.md; line 77Following this quick start fails before launching the title because
scripts/play.ps1has noConsoleparameter. Its own usage documentsscripts\play.ps1 -Exe <path of your own copy's executable>, and its parameter block at lines 15–21 accepts onlyExe,Safe,RayTracing,Build, andMore; line 47 already hard-codes--console series-s. The new-Machineand upscaler examples likewise target parameters absent from this script. Update the examples to the checked-in launcher API or include the corresponding launcher implementation.Useful? React with 👍 / 👎.
Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-12-01T03:11:49Z.
Code review location:
crates/victory-hle/src/modules/kernel.rs; line 427On normal
exit(), UCRT invokes the EXE TLS callback before executing itsatexittable. Enqueuing the callback here instead makes every cleanup registered later run before the title's TLS destructors. For example, a function-local static initialized during gameplay can be destroyed before a titlethread_localdestructor that still uses it, introducing use-after-destruction or shutdown crashes even without Tracy. Preserve the pre-atexitordering and cover it with a process-exit regression test; the current test invokes the callback runner directly and cannot detect this reversal.Useful? React with 👍 / 👎.
Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-12-01T03:11:49Z.
Code review location:
docs/replay.md; line 26This procedure never produces the promised
scene-<frame>.png: a repository-wide search findsVICTORY_CAPTURE_SCENE_BEFORE_FRAMEGEN,scene-next, andscene-traceonly in this new documentation. The implementedcapture::poll_requestconsumesnext-frame.requestwithVICTORY_CAPTURE_ON_REQUEST, whilecapture::save_aswrites half-sizeframe-*images. Consequently, users following these instructions cannot obtain the claimed full-resolution pre-interpolation capture for visual comparisons. Document the supported capture behavior or include the scene-capture implementation with this how-to.Useful? React with 👍 / 👎.
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.