Skip to content

gta6rt: keep a crashed run out of Windows Error Reporting (no locked gta6rt.exe, LNK1168) - #7717

Open
thedarkcr0w wants to merge 1 commit into
ItsNotRexed:mainfrom
thedarkcr0w:wer-no-report
Open

thedarkcr0w wants to merge 1 commit into
ItsNotRexed:mainfrom
thedarkcr0w:wer-no-report

Conversation

@thedarkcr0w

Copy link
Copy Markdown

Claimed in #7496 (new RT item: #7496 (comment)).

Problem. A gta6rt --run that ends in an unhandled exception is reported to Windows Error Reporting. Now and then the report leaves the ended run behind as a gta6rt.exe with no threads that Stop-Process -Force cannot end. It keeps runtime\build\gta6rt.exe open, so the next build fails with LINK : fatal error LNK1168: cannot open gta6rt.exe for writing until the file is renamed or the machine restarts. Anyone iterating on the retail boot (docs/boot.md, docs/retail_boot_chain.md) hits it. #6460 fixes the same mechanism for tiny_game_abort_test's children; nothing covered gta6rt.exe itself.

Change.

  • runtime/src/main.cpp: the first thing wmain does is SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX), before the base-reservation relaunch, so a relaunched gta6rt inherits it. The run still ends with the exception's code as its exit code. LEONIDA_WER=1 keeps the system default for anyone who wants a WER dump. Nothing outside the process is changed (no registry WER exclusion).
  • runtime/test/fixtures/tiny_game.cpp: two modes, error-mode (exit 43 when SEM_NOGPFAULTERRORBOX is set, 44 when not) and crash (an unhandled access violation).
  • runtime/test/tiny_game_wer_test.cpp (CTest run_tiny_game_wer): starts gta6rt with CREATE_DEFAULT_ERROR_MODE so it cannot inherit CTest's mode, then checks the mode by default and with LEONIDA_WER=1, and that a crash still exits with 0xC0000005.
  • docs/boot.md: LEONIDA_WER in the list of switches.

Tested on Windows 11 (10.0.26200), MSVC 2022 Build Tools RelWithDebInfo, NVIDIA GeForce RTX 4090 (driver 32.0.16.1062), at main 99d799a64:

main this PR
tiny_game_wer_test FAIL: default run has no SEM_NOGPFAULTERRORBOX (exit 44) 3/3 PASS
tiny_game crash under gta6rt --run: exit code / Application-log events (1000/1001) 0xC0000005 / 1 0xC0000005 / 0
retail gta6rt --run (own 1.0.2.1 copy; on main it stops early with an unhandled exception), 4 runs each: WER events / zero-thread gta6rt.exe left behind 4 / 1 0 / 0
full ctest 112/112 passed (8 skipped or disabled as on main: package-gated and GameInput)

A tiny_game crash is reported on main but leaves no process behind, so the test checks the error mode rather than the leftover; the leftover was seen only with the retail run (which is much larger). scripts/check_no_game_data.py passes on the changed files. No game files are needed for the test and nothing here quotes the executable.

AI-assisted (Claude Code).

A run that ends in an unhandled exception was reported to WER. Now and then
the report left the ended run behind as a process with no threads that
Stop-Process cannot end, keeping runtime\build\gta6rt.exe open so the next
build failed with LNK1168 until the file was renamed or the machine restarted
(the same mechanism ItsNotRexed#6460 fixes for tiny_game_abort_test's children).

gta6rt now sets SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX first thing, so
a relaunched gta6rt (base_reservation.h) inherits it. The exit code is still
the exception's code. LEONIDA_WER=1 keeps the system default for anyone who
wants a WER dump.

tiny_game gains an error-mode probe and a crash mode; tiny_game_wer_test
starts gta6rt with CREATE_DEFAULT_ERROR_MODE and checks the mode with and
without LEONIDA_WER=1 and that a crash still exits with 0xC0000005.

AI-assisted.
@MartinIndra02

Copy link
Copy Markdown

AI-assisted review/test.

PASS on commit �4b73a07dff5aedaa71b5ce29c44bff42dfcb63e.

  • Environment: Windows 11 x64, MSVC 19.44.35220, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.1, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124 / 621.24).
  • Build: cmake --build --target gta6rt tiny_game tiny_game_wer_test (Ninja, RelWithDebInfo) — succeeded cleanly.
  • Test: ctest -R run_tiny_game_wer --output-on-failure — 1/1 passed (
    un_tiny_game_wer, 0.32s).
  • Review: keep_crashes_out_of_wer() sets SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX at the start of wmain (preserving LEONIDA_WER=1 opt-out and exception exit codes), and iny_game_wer_test verifies both modes and the �xC0000005 crash exit code.

@Envyre

Envyre commented Nov 23, 2026

Copy link
Copy Markdown

Code read of b4b73a0 plus a native probe (Windows 11 x64, standalone program outside the repo, no registry/WER settings touched): looks good. SetErrorMode at main.cpp:66-74 is process-local (no registry, no WerAddExcludedApplication) and runs before any title code. Measured: without the flag an access violation starts WerFault.exe and takes ~1.3-2.3 s to end; with SEM_NOGPFAULTERRORBOX WerFault.exe never starts and the process ends in ~15 ms, exit code still 0xC0000005, vectored handlers still run. Inheritance: a child gets mode 0x3 unless created with CREATE_DEFAULT_ERROR_MODE; the only child gta6rt starts is its own relaunch (base_reservation.h:118).

Non-blocking:

  1. Fail-fast isn't covered: /GS cookie failures, CFG and the UCRT's abort() end in __fastfail (0xC0000409), and with SEM_NOGPFAULTERRORBOX set, __fastfail still started WerFault.exe in 4 of 4 probe runs, so the LNK1168 lock can still happen for those. docs/boot.md:81-84 ("keeps crashes out of WER") could say "unhandled exceptions (not fail-fast)".
  2. Skipping WER also skips WER LocalDumps (and likely the AeDebug JIT prompt); worth a line that LEONIDA_WER=1 brings them back.
  3. The crash check in tiny_game_wer_test.cpp passes with or without the flag (same exit code); the error-mode checks are what actually test this.

AI-assisted (Claude Code).

@Kerwinss

Copy link
Copy Markdown

Tested b4b73a0 on Windows 11 Pro 10.0.26300, MSVC 14.51, CPU only: pass.

Merged onto main dde82f2: build OK, ctest 112/112, including the new run_tiny_game_wer. Code read: the error mode is set before anything else in wmain, so the relaunched process inherits it. LEONIDA_WER=1 keeps the system default.

AI-assisted (Claude Code). No game files.

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.

4 participants