Skip to content

gta6rt: LEONIDA_PROBE logs the registers at chosen RVAs of the executable (finds which call of a retail init failed) - #7555

Closed
jacksonslab wants to merge 1 commit into
ProjectLeonida:mainfrom
jacksonslab:rt-probe-diagnostic
Closed

jacksonslab wants to merge 1 commit into
ProjectLeonida:mainfrom
jacksonslab:rt-probe-diagnostic

Conversation

@jacksonslab

Copy link
Copy Markdown

Claimed in the coordination issue: #7231 (comment) (new RT diagnostic item).

Depends on: none.

What and why

The retail boot keeps stopping on asserts that fire after a long init function returns false. Finding which call inside it failed has meant reading thousands of instructions or attaching a debugger. LEONIDA_PROBE does it from the command line:

  • LEONIDA_PROBE=<rva>[,<rva>...] (hex, as the trace's module+RVA prints them), with --trace, puts a breakpoint at each RVA of the mapped main image. It's armed in main.cpp right after loader.load, before any image code runs. An RVA outside the image is ignored with a line.
  • On a hit, the startup-trace handler logs a probe event (and an [probe] stderr line) with the general registers and the qword at rsp, which is the return address at a function's first instruction. It then puts the original byte back, runs the instruction under the trap flag, and re-arms the breakpoint on the single-step. Execution continues unchanged.
  • LEONIDA_PROBE_MAX=N logs N hits per address (default 16).
  • LEONIDA_PROBE_MEM=1 also logs the first 8 qwords at rdi and rsi, read with ReadProcessMemory, so a bad pointer prints -.
  • docs/boot.md lists it under "Useful switches". It says that registers and memory can hold game data, so the output stays on the player's machine and only what it shows is reported.

Put a probe on the instruction after each call, and the first rax that is an error names the call. On my own copy that's how two stops were found (details in the claim comment): the graphics init failing on an E_NOTIMPL from the fifth CreateCommandSignature, which #7330 fixes, and the slot-25 size assert on a B5G5R5A1 UAV target and an R32G8X24 depth-stencil + UAV target.

Tested

Windows 11, i7-14700K, RTX 4070 SUPER, MSVC 2022 (14.44) RelWithDebInfo, Visual Studio generator, on main 9f53c502e:

  • New probe_test (CTest probe): OK. It probes the second instruction of a synthetic three-instruction function with LEONIDA_PROBE_MAX=2:
    • three calls return the right values, and the probe is armed again after the last;
    • two probe events are logged, with rax before the instruction ran;
    • an RVA outside the image is ignored;
    • no probe hit reaches the exception log.
  • int3_skip_test: all checks passed. startup_trace_test: 26 checks, 0 failed.
  • python -I scripts/check_no_game_data.py: exit 0.
  • Retail executable: used on a local boot stack to find the two stops above. Without the variable nothing is armed, and the handler returns before touching an empty probe list.

No game data: the PR contains no addresses, offsets or bytes from the executable.

AI-assisted: yes (Claude Code).

🤖 Generated with Claude Code

…able

A diagnostic for the retail boot: with --trace, LEONIDA_PROBE=<rva>[,...] puts a
breakpoint at each RVA of the mapped main image. A hit logs the general registers and
the return address (a "probe" event and an [probe] line), puts the original byte back,
runs the instruction under the trap flag and re-arms the breakpoint. LEONIDA_PROBE_MAX
sets how many hits per address are logged (16), LEONIDA_PROBE_MEM=1 adds the qwords at
rdi and rsi. A probe after each call of a long init function names the one that failed.
probe_test runs it on a synthetic function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TillusStark26

Copy link
Copy Markdown

Independent Windows + MSVC review and test of bc0471a55: tests pass; code audit findings below.

Setup: Windows 11 Pro (10.0.26100 x64), MSVC 19.44.35230.0 (RelWithDebInfo, Ninja, -DLEONIDA_REQUIRE_VULKAN=ON), Vulkan SDK 1.4.363.1, no game files.

Tests run (synthetic only):

  • cmake --build <build> --target probe_test int3_skip_test gta6rt: PASS (exit 0).
  • probe_test.exe: PASS (exit 0; 9/9 checks OK, including LEONIDA_PROBE_MAX=2 cap, register logging, and re-arming).
  • int3_skip_test.exe: PASS (exit 0; 5/5 checks OK).

Code findings (runtime/shims/startup_trace.h):

  1. Unchecked dereference of c.Rsp inside the VEH (detail::probe): const auto ret = c.Rsp ? *reinterpret_cast<const uint64_t*>(c.Rsp) : 0; directly reads guest stack memory in the exception handler (unlike LEONIDA_PROBE_MEM, which safely uses ReadProcessMemory right below). If a probed site has a misaligned/unmapped rsp, this faults recursively inside the VEH. Using ReadProcessMemory for ret avoids that.
  2. Multi-threaded breakpoint re-arm race (probe_rearm / write_code_byte): write_code_byte runs outside probe_mutex() on both disarm and single-step re-arm, and two threads hitting the same 0xCC concurrently can interleave: thread A re-arms 0xCC on EXCEPTION_SINGLE_STEP before thread B executes its single-stepped original instruction (leaving thread B hitting 0xCC again with probe_rearm != nullptr), and concurrent VirtualProtect calls can restore PAGE_EXECUTE_READWRITE as old. Worth either serializing/documenting as single-thread/best-effort diagnostic or holding a lock/checking VirtualProtect carefully.
  3. Duplicate RVAs / existing 0xCC in install_probes: Passing the same RVA twice (e.g. LEONIDA_PROBE=3,3) pushes two entries where the second captures original = 0xCC; similarly, arming a byte that is already 0xCC causes infinite single-step/breakpoint recursion. Deduplicating RVAs and refusing *at == 0xCC avoids this.
  4. Ignored VirtualProtect failure in write_code_byte: write_code_byte returns void silently if VirtualProtect fails, so install_probes still pushes to probes() and logs [probe] armed at +0x.... Returning bool lets install_probes report the failure and skip registering an unarmed probe.

AI-assisted review and test.

@sgonzalez-glitch

Copy link
Copy Markdown

Tested bc0471a55 (merged with #7540 and #7541 onto main dde82f27e) on NVIDIA GeForce RTX 2080, driver 621.24 (32.0.16.2124), Windows 11, MSVC 19.44 RelWithDebInfo: pass.

AI-assisted: yes

@2-CD

2-CD commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Windows + GPU check (host-side probe tool). Hardware: NVIDIA GeForce RTX 5080 + RTX 3070 Ti (driver 621.01) and AMD Radeon 610M iGPU (Ryzen 9 9950X3D, driver 32.0.13018.6). OS: Windows 11. Toolchain: MSVC (VS BuildTools 18) + Ninja, single-config RelWithDebInfo; llvm-mc 21.1.8; SPIRV-Tools. Configured with -DLEONIDA_LLVM_MC and -DLEONIDA_SPIRV_AS/VAL.

Tested head bc0471a (base 1ce6eb5).

Build: 381/381 targets, 0 errors/warnings.

Targeted tests, --repeat until-fail:3 on the RTX 5080: probe (the new test this PR adds) and startup_trace - both pass x3.

Full runtime suite, ctest -C RelWithDebInfo -j 6, excluding the 4 windowed present tests: RTX 5080 268 run, 2 failed - d3d12_vulkan_device, d3d12_indirect_dispatch_count. This PR's diff is host-side only (startup_trace.h, main.cpp, probe_test.cpp, CMakeLists.txt, docs) - it touches no GPU / D3D12 device code, so it cannot have introduced these GPU-test failures; they are base-line (the same two are red on current main dde82f2, established earlier this session).

Scope note: the change is a host-side register-probe / logging tool with no GPU or present/swapchain code path, so I scoped this check to the NVIDIA full suite plus the new probe test rather than re-running the iGPU and present passes.

Net: the new probe test and startup_trace are green x3; the only full-suite failures are base-line GPU tests outside this host-side PR's scope.

Synthetic fixtures only, no game files. AI-assisted (opencode); runs on my machine.

@Ueslii

Ueslii commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested bc0471a55569017feb810f282472cc840a5b54f9 on Windows 11 Pro (10.0.26200 Build 26200), AMD Ryzen 5 5500, 16 GB RAM, AMD Radeon RX 5600 XT (RDNA 1, Adrenalin / Vulkan driver 26.11.2, Windows driver 32.0.21045.29003, Vulkan 1.4.315), MSVC 19.52.37029.0 (VS 2026, Ninja RelWithDebInfo), Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.1 (synthetic inputs, no game files): pass.

  • py -I scripts/check_no_game_data.py docs/boot.md runtime/CMakeLists.txt runtime/shims/startup_trace.h runtime/src/main.cpp runtime/test/probe_test.cpp: exit 0.
  • cmake --build runtime\build --config RelWithDebInfo --target probe_test int3_skip_test startup_trace_test gta6rt: exit 0.
  • ctest --test-dir runtime/build -C RelWithDebInfo -R ^(probe|int3_skip|startup_trace|gta6rt_) --output-on-failure -V: 7/7 passed (0.44 s):
    • startup_trace: Passed (0.09 s, 26 check(s), 0 failed)
    • int3_skip: Passed (0.05 s, all checks passed)
    • probe: Passed (0.06 s, probe_test: OK)
    • gta6rt_rejects_dry-run_run, gta6rt_rejects_dry-run_init, gta6rt_rejects_init_run, gta6rt_stack: Passed

AI-assisted.

@optinium51-bot

optinium51-bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Tested bc0471a55 merged onto main f837d4fe9 (clean merge) on NVIDIA GeForce RTX 3060 (driver 616.92), Windows 11 26200, MSVC 14.52 (VS 2026), RelWithDebInfo + Ninja: pass.

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

@BeetjeMatig

Copy link
Copy Markdown

Tested bc0471a (head of this PR) on RTX 5070 Ti (Blackwell, subgroup 32), NVIDIA 621.01, Windows 11, MSVC 14.44 (VS 2022 17.14 Build Tools), CMake 4.5.1 + Ninja, Vulkan headers sdk-1.4.363.0 (fetched), no game copy: pass.

I applied the diff to a clone of main at dfe4e4a (clean git apply), built probe_test (new in this PR) and ran it: exit 0, "probe_test: OK", including "the second hit sees the next argument" and "no probe hit reaches the exception log". The test is new, so there is no main to compare against; I did not run the LEONIDA_PROBE option against a real executable, as there is no game copy.

AI-assisted (Claude Code): checked by applying the diff to a private clone of main and building and running the tests above. No game data was used.

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