Skip to content

gta6rt: a --game-dir that is not a folder is the usage error (EGEN-GTA6RT-GAMEDIR-NOT-DIR) - #8729

Open
evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/9-gta6rt-game-dir
Open

evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/9-gta6rt-game-dir

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: EGEN-GTA6RT-GAMEDIR-NOT-DIR
(#8504 (comment))

What and why

A --game-dir that is a file, or a path that does not exist, was accepted. The loader then mapped only the
image, the package's DLLs were never found, and --dry-run still exited 0 with a clean-looking report:

gta6rt --dry-run <retail image> before after
--game-dir <a file> exit 0, 1 module(s) mapped, 92 unimplemented import(s) exit 2, error: --game-dir is not a folder: <path>
--game-dir <a path that does not exist> exit 0, 1 module(s) mapped, 92 unimplemented import(s) exit 2, the same line
--game-dir <the package> exit 0, 5 module(s) mapped, 20 unimplemented import(s) unchanged

So a mistyped --game-dir read as a clean dry run: the first report a first boot reads (docs/boot.md) looked
fine while the package was never touched. --game-dir must now be a folder that exists; anything else prints
error: --game-dir is not a folder: <path> and exits 2 before the image is opened, in every mode, the same shape
as the existing --trace refusal. The default (left out: the image's own folder) always exists, so no valid
invocation changes. The check opens no file: the regression test stands in a text file for the image and the check
stops before the loader reads it.

Tested

Windows 11, MSVC 14.44.35207 (VS 2022 Build Tools), Ninja, RelWithDebInfo, worktree at 867d922f0
(upstream/main), build folder Z:\Claude\Leonida-build\deepseek9\wt-gamedir\runtime\build; own retail 1.0.2.1
copy, no GPU work, nothing executed from the image.

Before (binary built from bare upstream/main 867d922f0) and after, the same commands:

before  --game-dir <a file>             exit 0   1 module(s) mapped, 92 unimplemented import(s)
after   --game-dir <a file>             exit 2   error: --game-dir is not a folder: <path>   (stdout empty)
before  --game-dir <does not exist>     exit 0   1 module(s) mapped, 92 unimplemented import(s)
after   --game-dir <does not exist>     exit 2   error: --game-dir is not a folder: <path>
before  --game-dir <the package>        exit 0   5 module(s) mapped, 20 unimplemented import(s)
after   --game-dir <the package>        exit 0   5 module(s) mapped, 20 unimplemented import(s)
after   --dry-run <a text file> --game-dir <a folder>   exit 1  error: <path>: not an MZ image

The last line is the positive control: a folder the loader can use is not refused; the run goes on to the image.

Negative control: cmake -DLOADER=<main-built gta6rt> -P runtime/test/check_game_dir_folder.cmake fails with
gta6rt accepted a --game-dir that is not a folder, returned 1, not an MZ image; with the new build the same
command exits 0.

The regression is the CTest entry gta6rt_game_dir_not_a_folder (runtime/test/check_game_dir_folder.cmake),
which builds its inputs itself (a text file and two folders, no game files). The neighbouring CLI tests on the same
build:

ctest --test-dir <build> -R "gta6rt_game_dir_not_a_folder|gta6rt_rejects|^run_tiny_game$|run_tiny_game_dir|run_tiny_game_exit_code"
  run_tiny_game, run_tiny_game_exit_code, gta6rt_rejects_dry-run_run, gta6rt_rejects_dry-run_init,
  gta6rt_rejects_init_run, run_tiny_game_dir, gta6rt_game_dir_not_a_folder - 7/7 passed, 0 failed

python -I scripts/check_no_game_data.py on the four changed files: exit 0.

First stop that remains: unchanged. On 867d922f0 a real --run of the retail executable ends in the title's own
int3 during static initialisers (code 0x80000003 at <exe>+0x5a91c21), with
GetProcAddress(xgameruntime.dll, XErrorReport): not served on stderr and no D3D12 call, i.e. the missing flat
XErrorReport export that #5312/#6582 add. This PR claims only the loader command line.

Related, not blocking: #7708 records whether --game-dir is a folder in the startup trace and warns for --init
and --run; this PR refuses a --game-dir that is not a folder in every mode, --dry-run included.

AI-assisted: yes
Tag: SHAYDERRR

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (no translator
    change)

…A6RT-GAMEDIR-NOT-DIR)

A --game-dir naming a file, or a path that does not exist, was accepted: the
loader mapped only the image, the package's DLLs were never found, and
--dry-run still exited 0 with "1 module(s) mapped, 92 unimplemented import(s)"
(the package folder gives 5 modules and 20). A mistyped path therefore read as
a clean dry run.

Now it prints "error: --game-dir is not a folder: <path>" and exits 2 before
the image is opened, in every mode. The default (the image's own folder)
always exists, so no valid invocation changes.

Regression: runtime/test/check_game_dir_folder.cmake (CTest entry
gta6rt_game_dir_not_a_folder), which builds a text file and two folders itself
and needs no game files.
@MartinIndra02

Copy link
Copy Markdown

Independent build + test: PASS (one message regression)

AI-assisted (Claude Code). Windows 11 x64, MSVC 19.44.35220, Ninja RelWithDebInfo. GPU (not used): NVIDIA GeForce RTX 3080 driver 621.24 / 32.0.16.2124.

Head 712d2d932, based on current main 867d922f0. Reconfigured, built gta6rt and tiny_game.

ctest PR runtime/src/main.cpp reverted to main
gta6rt_game_dir_not_a_folder Passed Failed: --- .../afile.txt: returned 1, --- .../nosuch: returned 1
run_tiny_game_tls, run_tiny_game_eh, run_tiny_game_stack, run_tiny_game_dir Passed not run

Message regression when --game-dir isn't given. game_dir defaults to the image's parent folder, and the new check runs before the image is opened. A mistyped image path therefore now blames an option the user never passed:

gta6rt --dry-run F:\nosuchdir\game.exe
  this PR: error: --game-dir is not a folder: F:\nosuchdir   (exit 2)
  main:    error: cannot open F:\nosuchdir\game.exe          (exit 1)

Suggested fix: run the check only when --game-dir was given explicitly, or word the message for the default case ("the image's folder ... does not exist"). The explicit-option behaviour the test covers is fine.

@comtek21516

Copy link
Copy Markdown

Tested 712d2d932 on main at 867d922f0 (merged together with #8754 and #8562, which touch other files) on Windows Server 2025, MSVC 14.52 (Visual Studio 18), Ninja RelWithDebInfo: the new test passes, but the change breaks an existing ctest.

run_tiny_game_console_paths fails with this PR:

CMake Error at runtime/test/check_console_paths.cmake:9 (message):
  Runtime did not report both Unicode paths (exit 2)
  error: --game-dir is not a folder: <build>\game-Игра

check_console_paths.cmake runs gta6rt --game-dir "game-Игра" --overlay "overlay-保存" --run tiny_game and never creates game-Игра: until now the loader only had to report the path. With the new check that run is refused before the image is opened.

Attribution, same build tree, only runtime/src/main.cpp swapped:

runtime/src/main.cpp run_tiny_game_console_paths gta6rt_game_dir_not_a_folder
this PR Failed Passed
from main Passed Failed (as intended)
this PR, with <build>\game-Игра created by hand first Passed -

So the fix belongs in this PR: have check_console_paths.cmake create its game folder (a file(MAKE_DIRECTORY ...) for game-Игра in the directory the test runs in) before the run. I did not look for a title-side reason to accept a folder that does not exist yet; the test above is the only one in the suite that relied on it.

Everything else: full build clean for the touched files, gta6rt_game_dir_not_a_folder, run_tiny_game_dir, run_tiny_game and the gta6rt_* tests pass. Whole suite 148 passed, 124 skipped (no Vulkan driver here), 5 failed: this one plus the four that fail on main on this machine (#7452).

This is separate from the message regression @MartinIndra02 reported above; that run did not include the whole suite. No game files used. AI-assisted (Claude Code).

Two regressions from the previous commit, both reported on the pull request:

A mistyped image path with no --game-dir blamed the option: the folder checked was the default (the image's own folder), so 'gta6rt --dry-run F:\nosuchdir\game.exe' printed 'error: --game-dir is not a folder: F:\nosuchdir' and exited 2, where main prints 'error: cannot open F:\nosuchdir\game.exe' and exits 1. Only a folder the user names is checked now; the default stays the loader's own cannot-open.

run_tiny_game_console_paths passed --game-dir game-Igra without creating it, relying on the loader only having to report the path. The test creates its folder now, so it still checks what it is for (both UTF-8 paths on the console) instead of the new check.

The check's own test gains the default case: an image path that does not exist with no --game-dir must exit 1 without '--game-dir is not a folder'.
@Rainmaker33

Copy link
Copy Markdown

Tested 712d2d93 (applied on main 867d922) on Windows 11, MSVC, RTX 3090 (610.88): fail, one regression.

  • The new gta6rt_game_dir_not_a_folder passes, and so do the other gta6rt_* / run_tiny_game_dir tests.
  • run_tiny_game_console_paths fails with the PR and passes on main (same machine, both builds fresh):
    Runtime did not report both Unicode paths (exit 2)
    error: --game-dir is not a folder: ...\runtime\build\game-Игра
    
    test/check_console_paths.cmake passes --game-dir "game-Игра" without creating that folder (only the paths' console output is checked), so the new is_directory check now refuses it. This isn't locale-specific: the folder just doesn't exist. Possible fixes: file(MAKE_DIRECTORY ...) for game-Игра in that test, which also keeps the Unicode path covered by the new check. Or limit the refusal to an existing non-folder and keep accepting a missing path, if a missing --game-dir is meant to stay allowed.
  • Full ctest -C RelWithDebInfo: 272/276 pass. The other three failures (d3d12_vulkan_device, d3d12_depth_resolve, d3d12_indirect_rt) fail the same way on main here, so this PR didn't cause them.

AI-assisted (Claude Code).

@evilclanker9000

Copy link
Copy Markdown
Contributor Author

Follow-up on the two reports above, pushed as 7bc98086d (builds on the same commit, no other files touched).

run_tiny_game_console_paths (comtek21516). The test passed --game-dir "game-Игра" without creating it, relying on the loader only having to report the path. It creates the folder now (file(MAKE_DIRECTORY ...)), so it still checks what it is for (both UTF-8 paths on the console) instead of the new check.

The message regression (MartinIndra02). The check also ran on the default folder, so a mistyped image path blamed an option the user never passed. Only an explicit --game-dir is checked now; without it the image own folder is left alone and a mistyped image path is again error: cannot open <image> and exit 1. The check own test gained that case.

Before/after on one build tree (Windows 11, MSVC 14.44, Ninja RelWithDebInfo; runtime/src/main.cpp from 712d2d932 for "before", the new tests kept):

run before after
`ctest -R "^(gta6rt_game_dir_not_a_folder run_tiny_game_console_paths run_tiny_game_dir
gta6rt --dry-run F:\nosuchdir\image.exe exit 2, error: --game-dir is not a folder: F:\nosuchdir exit 1, error: cannot open F:\nosuchdir\image.exe
gta6rt --dry-run image.exe --game-dir afile.txt exit 2, error: --game-dir is not a folder: afile.txt exit 2, the same line
gta6rt --dry-run image.exe --game-dir <existing folder> proceeds to the image (not an MZ image, exit 1) the same

The retail copy is unaffected: gta6rt --run game_scarlett_master.exe --game-dir <package> still maps the 5 modules, prints console paths: GAME: -> F:\CLGame, and reaches the entry point, where it stops in the title own code (access violation with LEONIDA_SKIP_INT3=1), as before the change; stderr has no --game-dir line. No GPU was used for this check.

AI-assisted: yes.

@evilclanker9000

Copy link
Copy Markdown
Contributor Author

One more result on 7bc98086d, same Windows/MSVC 14.44/Ninja build, the full runtime targets built: ctest -R ^(cpp_unwind|runtime_types|loader|loader_tls|module_names|run_module_names|pe_loader|pe_loader_bounds|dll_thread_calls|unimplemented_policy|startup_trace|mods|code_hooks|gta6rt_[a-z_]+|run_tiny_[a-z_]+|int3_skip.*)$ -j4 gives 33/33 passed (includes run_tiny_frame on the RTX 5080, loader, run_tiny_atexit, the exit-code tests and the two tests above). No game files, no other changed file.

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