gfx_window_win.c wnd_proc ran gfx_window_closed, which does not return, on the window thread for WM_CLOSE and
WM_ENDSESSION. While pipeline builds run the end takes seconds (vk_pipeline_save_exit waits up to 5 s), and the
window stopped pumping meanwhile: after 5 s Windows showed it as not responding, and an "End task" there killed
the process in the middle of its saves.
WM_CLOSE now starts an "exit" thread that runs gfx_window_closed (exit_start; the end runs on the window thread as
before should no thread be made) and returns 0, so the pump goes on. The window is hidden as the end starts, so a
window that still answers does not invite a second close; one would find the end under way in rt_exit_begin.
WM_ENDSESSION(TRUE) starts the same thread and waits for it on the window thread, since Windows ends the process
once that message returns; after a close had started the end it waits as well. The SDL window is unchanged.
ShutdownBlockReasonCreate was left out: called at WM_ENDSESSION it is too late to show a reason.
Not reproduced before the change (a play-test item: close on the boot screen, the window must not ghost).
tests/exit_order_check.py checks statically that WM_CLOSE and WM_ENDSESSION go through exit_start, which hides the
window, and that the session's end joins the thread; it and the compile checks pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cheats.c rebuild_if_needed runs in rt_boot after the prewarm thread has started, and ended the process with only
prof_write and rtss_limit_restore. By then vk_pipeline.c may have written pipeline-prewarm-running.txt (pm_set) and
opened the boot's journal of library builds; left in place, the next start took the rebuild's end for a driver crash
in the boot's builds (pm_skipped counts it as a quiet end; three of them skip the prebuild). The rebuild.skip file
keeps it to one quiet end per rebuild.
The rebuild's end now takes the orderly end's guard (rt_exit_begin), puts RTSS's profile back, clears the prewarm
marker, closes the boot's journal through the new vk_pipeline.c vk_pipeline_boot_abandon (journal_close, as
vk_pipeline_save_exit does), writes the summary and ends. No save is mounted and no menu has run yet, so the saves and
nx2navi.ini have nothing to write. A narrow race stays: pm_set writes the marker and then sets pm_on, so a clear in
between leaves the file; the window's close has the same one.
tests/exit_order_check.py checks that order in rebuild_if_needed. Not reproduced before the change;
exit_order_check and the compile checks of every runtime file pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main.c log_sink wrote nothing to the file once g_log_bytes passed LOG_CAP: every later line, the exit summary,
"frametime: exit", the stutter map's exit lines and FATAL and crash lines included, went to stderr only, which a
game started from the launcher or Explorer does not keep. A trace = perf session reaches the cap in about 90
minutes (the fresh 0.10.0 log grew 12 KB/s), and the play-test asks for an hour or more of exactly that. A reserve
compared against g_log_bytes would not help: that counter adds every line, dropped ones too, so 4 MiB of dropped
lines (under 6 minutes at that rate) would use it up before the end came.
The new rt_log_ending marks the process as ending; rt_exit_begin (the orderly ends) and perf_summary_flush (the
frame-time summary, also on the cheats rebuild exit) call it, and rt_log_sync (a fatal error, the crash report)
counts as ending too. The exit summary and the stutter map are written before rt_log_sync, so keying on
g_log_final alone would have missed them. While ending, a line past the cap goes to the file through
g_log_tail, a counter of the bytes written past the cap, up to LOG_END_RESERVE (4 MiB), after one line saying the
end of the run follows. The cut line says the end will still come. The file can end 4 MiB past the cap.
perf_summary_flush now calls rt_log_ending before ft_stop, so tests/exit_order_check.py's static check of it wants
ft_stop before ft_report rather than first. The check also prints one closing line for the static checks and the
program together: the program's own "ok" line had hidden a failing static check.
Not reproduced before the change (no log here reached the cap). The new tests/log_cap_check.py builds log_sink
with a 4 KiB cap and a 2 KiB reserve: past the cap ordinary lines are dropped with one cut line, and after
rt_log_ending or rt_log_sync the end's lines fill the reserve after one "end follows" line, however much was
dropped before. exit_order_check (rt_exit_begin marks the end once; exit code 0 at this commit), logq_check and the
compile checks pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The window's close, the guest's ExitProcess and the end of a --seconds run each ran their own list. All three
waited for the pipeline save (up to 5 s for running builds, then the write) before they put RivaTuner Statistics
Server's profile back, stopped HD rumble, wrote the frame-time summary and flushed the save, so a console close,
a session end or an "End task" that killed the process in that wait left the game's limit in RTSS's profile (the
next run takes it for the player's own), a buzzing controller and no exit summary. ExitProcess also lacked
cfg_save and the rumble stop, and it and the window's close had no shared guard, so both could run at once and
write the summary twice while the present thread still added to it.
gfx_present.c rt_exit_begin is the one guard (the first caller runs; another thread waits for good; the same
thread again returns, and svc.c ends the process then rather than resume guest code). rt_exit_steps runs, in
order: fs_save_wait (a Commit under way finishes, none is refused), rtss_limit_restore, input_rumble_hd_stop,
cfg_save (not for --seconds), the prewarm marker clear, prof_write, vk_mem_exit_log, a non-final log flush
(the new logq.c logq_flush, bounded trylocks, queue left on), vk_pipeline_save_exit, and fs_save_flush last.
perf.c ft_stop keeps the present thread's frame-time updates out of the exit's summary and waits at most 50 ms,
on the exiting thread, for one under way. The restore relies on rtss_limit.c's closed flag to stay restored
while frames go on during the pipeline save. The log order changes: "frametime: exit" and the stutter-map exit
lines now come before the pipeline save's lines.
Not reproduced before the change. tests/exit_order_check.py (new: the step order, the once-guard with a second
thread, ft_stop's wait and bound, and statically that the three exits use the helper with the RTSS restore
before the pipeline save), tests/logq_check.py (with a logq_flush case), tests/save_share_check.py and the
compile checks pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>