Skip to content

gta6rt: --log FILE appends the loader's and the title's output to a file - #7329

Open
GeremC wants to merge 2 commits into
ItsNotRexed:mainfrom
GeremC:gta6rt-log-file
Open

GeremC wants to merge 2 commits into
ItsNotRexed:mainfrom
GeremC:gta6rt-log-file

Conversation

@GeremC

@GeremC GeremC commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Item: new RT item claimed in #6910 (claim).

Why: Proton's default launch (a Steam "non-Steam game" shortcut, proton run, umu's default waitforexitandrun) starts the program through Proton's built-in steam.exe, which gives it no console. A player who starts gta6rt.exe that way gets none of the loader's output: no dry-run report, no [rt] lines, no error:. Only the exit code comes back. I measured this while testing #4213 (details): proton run, with or without a pty, and PROTON_LOG don't capture it either.

Change (runtime/src/main.cpp):

  • --log FILE, accepted in every mode, reopens stdout on FILE in append mode (_wfreopen_s), _dup2s stderr onto it, and SetStdHandles both. So the title's own CRT output, host code, and a process base_reservation starts again (it inherits the std handles and re-reads --log) all land in FILE.
  • Unbuffered, so a crash or ExitProcess loses nothing. Append mode, so the relaunched process and later runs add to the file.
  • An unopenable FILE gives error: cannot open the log file for appending and exit 1 before anything is mapped. The usage text lists [--log FILE].
  • README: one sentence where it explains gta6rt.sh --dry-run/--init/--run.

Test: run_tiny_game_log_file (runtime/test/check_log_file.cmake, on the synthetic tiny_game fixture) checks:

  • --dry-run --log F writes 1 module(s) mapped to F and not to stdout;
  • --run --log F -- hello 42 appends tiny_game: started, argc=3 … tiny_game: OK … game exited with code 0 after the first report, prints nothing of the guest's on the console, and exits 0;
  • a log path in a missing folder is refused.

Tested (Ubuntu 24.04, NVIDIA RTX 4090, real display; clang-cl 19.1.1 + xwin cross-build of current main with this change):

  • Proton Experimental's wine (wine-11.0) as CMAKE_CROSSCOMPILING_EMULATOR: run_tiny_game_log_file passes. All other run_tiny_game* and gta6rt_rejects_* tests pass too, except run_tiny_game_abort_exit_codes, which fails on main too (fixed by tiny_game_abort_test: the native reference accepts Wine's abort() exit code 3 #6539).
  • Through Proton's actual launch: proton run gta6rt.exe --run Z:<tiny_game.exe> --log Z:<file> -- hello 42 gives rc 0 and an empty console, and the file holds the guest's started/OK lines and game exited with code 0. Same with tiny_game_fixed.exe.
  • tests/test_docs_*.py: test_docs_cli_flags and test_docs_links fail on main too (docs/dev-tools.md); the rest pass.
  • Not run on Windows. Without --log nothing changes.

AI-assisted (Claude Code, Claude Opus 5.5).

🤖 Generated with Claude Code

https://claude.ai/code/session_014W1f1QexoRrV2Dg68CN4cD

Proton's default launch (a Steam shortcut, `proton run`, umu's
waitforexitandrun) starts the program through its steam.exe, which gives
it no console: none of the loader's report, [rt] lines or errors reach
the player, only an exit code.

--log FILE reopens stdout on FILE in append mode, points stderr at it and
sets the process's standard handles to it, so host code and a process
base_reservation starts again write there too. Unbuffered, so a crash
keeps what was printed. A log file that can't be opened is refused
before anything is mapped.

run_tiny_game_log_file checks the dry-run report and, appended after it,
the guest's own printf output and exit line, nothing on the console, and
the refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014W1f1QexoRrV2Dg68CN4cD

@Desamodeth Desamodeth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On native Windows (MSVC x64 Release, 6c5581e0), starting gta6rt --run tiny_game.exe --log FILE with DETACHED_PROCESS and no output pipes exits 1 before the guest starts. An existing log stays byte-for-byte unchanged. The current CTest passes because it gives the child output pipes.

With no console, the CRT can report a negative descriptor for stderr, so duplicating stdout onto it fails. The patch gives that stream a descriptor first. Its regression test reproduced the failure on this head. With the fix, the guest writes to the log and returns 42, and a second launch with a missing image appends its diagnostic after the first run. Eight focused CTests and all 15 combinations of launch mode and logging scenario passed on Windows with synthetic fixtures. CPU only, AI-assisted.

Cherry-pickable fix and regression test

SkippySteve added a commit to SkippySteve/Leonida that referenced this pull request Nov 23, 2026
--log (from ItsNotRexed#7329) takes a value; without it in the launcher's value list the
file name counted as an image and packaged defaults were dropped. Relative
--log paths now resolve against the caller's cwd like --trace.
@GeremC

GeremC commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Desamodeth, good catch: that detached case is exactly the one --log is for. I cherry-picked your commit as is (185a0c4dd, your authorship kept): the descriptor fix plus run_tiny_game_log_detached, which only runs on native Windows. Rebuilt and re-ran under Proton Experimental's wine on Linux: run_tiny_game_log_file, run_tiny_game, run_tiny_game_console_paths and the three gta6rt_rejects_* all pass (6/6).

AI-assisted (Claude Code).

@memorypressure

Copy link
Copy Markdown

Verified at 6c5581e, clean against current main 9177299. The --log plumbing reads right: append reopen unbuffered, stderr dup2'd onto stdout, SetStdHandle refreshed so host code and base_reservation inherit, bare trailing --log falls to usage(); check_log_file.cmake asserts the "1 module(s) mapped" line lands and appends across relaunch. The cmake-run test needs the Windows job; CI pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run, C++ review-only).

@Jadiac5

Jadiac5 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 185a0c4 on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass, with one finding

  • MSVC 19.44, CMake 3.31, Ninja, RelWithDebInfo, native Windows. Built gta6rt, tiny_game, tiny_game_fixed, tiny_game_exit_code_test, tiny_game_abort_test.
  • ctest -R "^(run_tiny_game.*|gta6rt_rejects.*)$": 15/15 pass, including the new run_tiny_game_log_file and run_tiny_game_log_detached.
  • Negative control 1: runtime/src/main.cpp put back to 6c5581e (without the detached-stderr fix), tests kept. run_tiny_game_log_file passes and run_tiny_game_log_detached fails. So the detached test does catch the missing descriptor fix.
  • Negative control 2: runtime/src/main.cpp put back to the merge base 8575d36 (no --log at all). Both new tests fail. Restored, both pass again.
  • Finding (comment only): in runtime/src/main.cpp lines 13-15 the new "Every mode takes --log FILE" paragraph sits between the gta6rt --run <exe> ... usage line (line 12) and its description (line 16 on). The --run description now reads as if it follows the --log text. Move the paragraph above line 3 or below the --run block.
  • Not done: Proton, Wine and Linux runs; the build of the other test targets. Not run against the retail executable.

AI-assisted (Claude Code).

@crastinator

Copy link
Copy Markdown
Contributor

Tested 185a0c4d merged onto main 3e1e6ea11 (clean merge) under plain Wine: pass.

Windows build cross-compiled with clang-cl 23.1.5 + xwin (SDK 10.0.26100) on CachyOS (Linux 7.3.5), run under Wine 11.22 (builtin d3d12/vkd3d, not Proton) on an AMD Radeon RX 6700 XT, RADV Mesa 26.3.1.

run_tiny_game run_tiny_game_log_file
main pass (not on main)
this PR pass pass (14.9 s)

That's plain Wine 11.22 next to your Proton (wine-11.0) run. I didn't try Proton's steam.exe launch path.

AI-assisted (Claude Code).

@myokex

myokex commented Nov 23, 2026

Copy link
Copy Markdown

Tested 185a0c4dd on Windows 11, AMD Radeon RX 7800 XT (RDNA3, driver 32.0.32029.2010), MSVC 2022 RelWithDebInfo, CMake 4.4.4, Vulkan SDK 1.4.363.0; merged alone onto main 042c5f378, full ctest -j8; synthetic, no game files: pass. 257/262; the new run_tiny_game_log_file and run_tiny_game_log_detached pass, and gta6rt_rejects_init_run, gta6rt_stack, xbox_present still pass. No new failures. The 5 failures main itself has on this card (vk_queue_query_sync, d3d12_vulkan_device, d3d12_texture_tiles, d3d12_indirect_dispatch_count, d3d12_pipeline_library_host, see #166) fail the same way with and without this PR. AI-assisted (Claude Code).

@karearl

karearl commented Nov 23, 2026

Copy link
Copy Markdown

Baseline on main here: d3d12_vulkan_device, d3d12_present and xbox_present fail on this machine without the PR too; no Vulkan SDK installed, so the glslang/llvm-mc shader tests were not built.

AI-assisted (Claude Code).

@YaBulochka

Copy link
Copy Markdown
Contributor

checked: #7329 | with: WINEPREFIX=/home/SSD/GEProto13-prefix/pfx /home/SSD/GE-Proton11-13-x86_64/files/bin/wine gta6rt.exe --dry-run game_scarlett_master.exe --log Z:\tmp\run.log | on: Linux, Wine 11.13 (GE-Proton 11-13, wine-11.0), main 3470223 + PR 185a0c4 (merge-base 8575d36) | result: pass, no regression found

Applied cleanly at the merge result and built with clang-cl/xwin (RelWithDebInfo, -DLEONIDA_SDL3=OFF); on the retail image (--dry-run only) the fresh log got the loader report (5 module(s) mapped, 22 unimplemented import(s)) and the three [rt] mods: lines from a synthetic mod, stdout/stderr stayed empty apart from Wine's own ntsync notice, and a second run left the first 8173 bytes byte-identical and doubled the file to 16346 bytes with two summaries. With --trace F --trace-d3d12, tiny_frame under --run put 19 gapless [d3d12-trace] lines in the log while the JSONL trace stayed 3 valid lines with no log line in it; a log path in a missing directory exits 1 with error: cannot open the log file for appending before mapping and creates nothing, while --log - just creates a file named - and --log "" is silently ignored (neither is documented). ctest -R "^(run_tiny_game.*|gta6rt_rejects_.*)$" was 13/14 including run_tiny_game_log_file; run_tiny_game_abort_exit_codes fails identically on clean main 3470223 (xgameruntime abort checks), and run_tiny_game_log_detached is not registered in a cross build, so it did not run here.

agent: yes

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.

8 participants