Skip to content

RT-486: Retain the import binding report when initialization fails - #6835

Merged
shayderrr merged 1 commit into
ItsNotRexed:mainfrom
rrrarrra9:contrib/rt-486-init-failure-report
Nov 23, 2026
Merged

shayderrr merged 1 commit into
ItsNotRexed:mainfrom
rrrarrra9:contrib/rt-486-init-failure-report

Conversation

@rrrarrra9

Copy link
Copy Markdown
Contributor

RT-486 coordination claim

A bundled DLL can return FALSE from process attach after the image and its imports have already been mapped. The initialization exception currently reaches the error handler before stdout gets the binding report. This loses information about the mappings and unresolved imports during first-boot triage.

Change

  • runtime/src/main.cpp retains the initialization exception until the existing binding report is printed and flushed, then propagates it through the original error path.
  • runtime/test/check_startup_cmdline.cmake requires the binding totals in the existing synthetic DllMain rejection case. The test also checks exit status 1 and that the guest entry point was not reached.

Validation

Windows 11 x64, Ryzen 5 4600H, MSVC 19.51.36260.0, Windows SDK 10.0.26100.0, CMake 4.4.3, Release CPU build. The tests used locally compiled synthetic fixtures and did not exercise a GPU.

  • Baseline 1cc6e3c1: run_startup_cmdline failed the new assertion. The synthetic DLL reported the expected DllMain rejection and the import report was missing.
  • Head 3f7c670: run_startup_cmdline passed all three fixture cases, including the rejection with two mapped modules and the binding totals. The focused runtime CTest selection passed 10/10.
  • python -I tests/test_boot_trace.py passed 20/20. Separate synthetic CLI smoke tests for --dry-run and --init both returned 0 and reported two mapped modules.
cmake -S runtime -B <cpu-build> -G "Visual Studio 18 2026" -A x64 -DCMAKE_SUPPRESS_REGENERATION=ON -DLEONIDA_SDL3_FETCH=OFF -DLEONIDA_BUILD_WINDOWS_RUNTIME=ON -DLEONIDA_VULKAN_HEADERS_FETCH=OFF -DLEONIDA_REQUIRE_VULKAN=OFF -DCMAKE_DISABLE_FIND_PACKAGE_Vulkan=ON
cmake --build <cpu-build> --config Release --parallel 3 --target gta6rt tiny_startup_cmdline loader_test startup_trace_test unimplemented_policy_test tiny_game
ctest --test-dir <cpu-build> -C Release --output-on-failure -R "^(loader|startup_trace|unimplemented_policy|run_startup_cmdline|run_tiny_game|run_tiny_game_console_paths|run_tiny_game_tls|run_tiny_game_eh|run_tiny_game_dir|run_tiny_game_stack)$"
python -I tests/test_boot_trace.py
git diff --check

This covers initialization failures surfaced as loader exceptions. Callback phase tracing for interrupted runs is tracked separately in #6410. Dependencies: none.

AI-assisted with OpenAI Codex.

RT-486. Emit the binding report while the loader owns the mapped modules, then propagate the original failure. Exercise the failure path with the existing synthetic DllMain rejection.
@gut0to

gut0to commented Nov 23, 2026

Copy link
Copy Markdown

Independent Windows check of 3f7c670: pass.

MSVC 19.44.35228, Windows SDK 10.0.26100.0, RelWithDebInfo; synthetic fixtures only, no game files and no GPU dependency.

  • loader, startup_trace, and run_startup_cmdline: 3/3 passed. The DllMain-rejection path retained the mapped-module and import-policy report as required.
  • run_tiny_game, run_tiny_game_console_paths, run_tiny_game_tls, run_tiny_game_eh, run_tiny_game_stack, and run_tiny_game_dir: 6/6 passed.
  • python -I tests/test_boot_trace.py: 20/20 passed.
  • git diff --check: clean.

AI-assisted.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

  • runtime/src/main.cpp catches std::exception from loader.initialise(), stores it in std::exception_ptr, still prints the mapped-module import binding report, then rethrows after flushing stdout.
  • runtime/test/check_startup_cmdline.cmake now asserts that the fail_init case preserves both the mapped-module and unimplemented-import report lines.

Why merge

A failed DLL attach previously lost the diagnostics operators need most. This preserves the binding report and exit status while keeping the failure semantics intact, with a test guarding the behavior.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

  • runtime/src/main.cpp catches std::exception from loader.initialise(), stores it in std::exception_ptr, still prints the mapped-module import binding report, then rethrows after flushing stdout.
  • runtime/test/check_startup_cmdline.cmake now asserts that the fail_init case preserves both the mapped-module and unimplemented-import report lines.

Why merge

A failed DLL attach previously lost the diagnostics operators need most. This preserves the binding report and exit status while keeping the failure semantics intact, with a test guarding the behavior.

Verdict: Approve

@shayderrr
shayderrr merged commit 1d73504 into ItsNotRexed:main Nov 23, 2026
@quackottu

Copy link
Copy Markdown
Contributor

Tested 3f7c670c against the retail engine exe (1.0.2.1): merged onto main d2c2ab778 cleanly, Windows 11, MSVC 19.44, RelWithDebInfo. These results do not depend on the boot.

  • gta6rt --dry-run and gta6rt --init on the exe both exit 0 and print the binding report: 5 modules mapped, 29 unimplemented imports, the same as main.
  • On this executable every bundled DLL's process attach succeeds under --init, so the failure path this PR changes isn't reached. There's no regression on the success path. The changed path itself can only be exercised with a DLL whose process attach fails, which this exe doesn't provide.

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