Skip to content

runtime: LEONIDA_SKIP_ASSERTS and caller logging for forwarded device slots (RT-526) - #228

Closed
Andretuta wants to merge 1 commit into
mainfrom
old-pr/9961
Closed

Andretuta wants to merge 1 commit into
mainfrom
old-pr/9961

Conversation

@Andretuta

Copy link
Copy Markdown
Collaborator

Carried over from old PR 9961 by slipperysquid in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9961, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
This branch conflicts with the current main and needs a rebase.
slipperysquid: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claimed in the coordination issue as: RT-526 (two RT-5 boot diagnostics)

Depends on: none

What and why

Two retail-boot diagnostics, as RT-526 specifies. Neither changes anything unless asked for.

  1. LEONIDA_SKIP_ASSERTS=N (runtime/src/assert_skip.h, installed by main.cpp under --init/--run before the first TLS callback). Without a debugger, a guest assert's int3 is an unhandled EXCEPTION_BREAKPOINT and the run ends there. This adds a vectored handler, registered last so every other handler sees the breakpoint first. It steps over up to N int3 (byte 0xCC) at addresses in no host module, which means the Loader's mapped images and code a title wrote itself. Each one gets a log line:
    [rt] LEONIDA_SKIP_ASSERTS: int3 at game.exe+0x1234 stepped over (1 of 3)
    After N it says so once, and the next int3 ends the run as before. It passes on:

    • an int3 in a host module (gta6rt, its shims, system DLLs);
    • a breakpoint with no 0xCC at its reported address;
    • a RIP that is neither at the 0xCC nor one byte past it.

    On x64 Windows, and measured here under Wine 10.0 (the test checks it), RIP is the 0xCC's own address, and the handler moves it one byte on. No --trace is needed. With a trace open, each skip is also an int3_skipped event with a skip count, and the trace's own handler records the breakpoint and its stack first.

    • 0 or unset installs nothing.
    • The value must be a decimal number up to 1000000. Anything else is reported and treated as 0.

    LEONIDA_SKIP_INT3 (trace-only, no limit, one log per address) stays as it is. The docs say how the two differ.

  2. Caller of each forwarded device slot. The first call of every device slot taken by the proxy's generic thunk now names its caller: device slot 25 (GetResourceAllocationInfo) first call from game.exe+0x1234. Those are the PC slots passed through by number, the routed Xbox slots 48/73/78/79/80, and the refused tail. The caller is _ReturnAddress() in the thunk, described through a new set_caller_describer, which gta6rt points at rt::shims::module_offset. With no describer, the bare address is logged. Slots with handlers of their own keep their current line. Until now, finding a slot's call site took a debugger.

Docs: runtime/README.md (new "Guest asserts" section, the trace table row), docs/boot.md (useful switches) and docs/d3d12_command_objects.md §5.2. tools/boot_trace.py's label for int3_skipped now names both switches.

Tested

All tests are synthetic. No game files, no game data.

  • Cross-build: Linux, clang-cl 21 / lld-link 21 against an xwin /winsysroot splat (MSVC 14.44, SDK 10.0.26100), runtime/cmake/clang-cl-xwin.cmake, Ninja, RelWithDebInfo. Tests ran under Wine 10.0 (Ubuntu 10.0~repack-12ubuntu1) through ctest's crosscompiling emulator.

    • assert_skip (new) passed. It covers value parsing; int3 in a VirtualAlloc'd page no host module owns; a limit of 2, where the third is passed on; a host-module __debugbreak passed on; a two-byte int 3 (CD 03) passed on; and RIP at the 0xCC under Wine.
    • int3_skip (existing) passed.
    • run_tiny_game_skip_asserts (new) passed. gta6rt --run tiny_game -- hello 42 int3 runs with LEONIDA_SKIP_ASSERTS=2: two int3 in the mapped stand-in game are stepped over (tiny_game.exe+0x…), and the game reaches its normal exit 0.
    • xs_proxy_mock with the new check_slot_callers passed, stderr captured. Checks:
      • slot 25 names its caller once, on its first call only;
      • routed slot 78 and refused slot 120 name theirs;
      • handled slot 36 has no caller;
      • with no describer, the bare address is logged;
      • the reset clears it.
  • Current upstream main (e56d979) does not build gta6rt, xs_proxy_mock_test or device_proxy_test, without this change too:

    • shims/d3d12_xs_device.cpp calls rt::d3d12::create_console_descriptor_heap with no declaration in scope. Its definition is in the Vulkan layer, which these targets don't link.
    • shims/acphal.cpp's SHAPE_XMA_CONTEXT/SHAPE_PCM_CONTEXT size static_asserts fail.

    So on that base, main.cpp and the new test objects were compiled and assert_skip/int3_skip were run. xs_proxy_mock was run with a local, uncommitted declaration and stub for create_console_descriptor_heap: the new check passes, and the existing check_console_command_list then fails at its slot-14 heap creation on that stub (not this change; the new check runs before it). The whole change was also built on the previous main (867d922), where everything links. There, gta6rt, xs_proxy_mock (all 6 tests), assert_skip, int3_skip, run_tiny_game_skip_asserts and the 18 gta6rt/loader/tiny_game tests all passed.

  • Linux portable subset: cmake -S runtime -B runtime/build/linux && cmake --build runtime/build/linux --parallel && ctest --test-dir runtime/build/linux --output-on-failure. 70/70 passed (2 skipped as usual: shader_library_corpus, vk_sync_validation).

  • python -I tests/test_boot_trace.py and python -I tests/test_docs_links.py pass.

  • python -I tests/test_docs_env_vars.py: LEONIDA_SKIP_ASSERTS is documented. The test still fails on upstream main for LEONIDA_RNG_SEED (runtime/shims/bcrypt_rng.cpp), which no document names. That predates this change.

  • python -I scripts/check_no_game_data.py on every changed file: clean.

  • Not run: native Windows/MSVC, and device_proxy_test (WARP, needs d3d12.dll). No GPU is involved.

AI-assisted: yes (Claude Code)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. The log lines shown are formats with placeholder offsets.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

… slots (RT-526)

Two diagnostics for the retail boot (RT-5 follow-ups), both off the hot path
and with no behaviour change unless asked for:

- LEONIDA_SKIP_ASSERTS=N (src/assert_skip.h, installed by main.cpp before any
  image code runs under --init/--run): a vectored handler, added last, steps
  over up to N int3 (0xCC) at addresses in no host module and logs each one as
  module+RVA (and as an int3_skipped trace event when --trace is open). After N
  it says so once and the next int3 ends the run as before. An int3 in a host
  module, a breakpoint with no 0xCC at its address, or a RIP that is neither
  at nor one past the 0xCC is passed on. Needs no --trace and no debugger.
- The first call of every device slot the Xbox device proxy's generic thunk
  takes by number (PC pass-through, the routed Xbox slots, the refused tail)
  logs its caller: the thunk's return address, described by
  set_caller_describer (gta6rt registers rt::shims::module_offset), else the
  bare address. device_slot_first_caller is the test helper.

Tests (synthetic, no game files): assert_skip_test (int3 in a VirtualAlloc'd
page, the limit, a host-module int3, a two-byte int 3, value parsing),
run_tiny_game_skip_asserts (two int3 in the mapped stand-in game, stepped over
end to end), and xs_proxy_mock_test's check_slot_callers (stderr captured).

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

Copy link
Copy Markdown

Carried over in two parts, so the two RT-526 drafts no longer overlap:

Once #1395 and #1390 are reviewed, this draft can be closed in their favour.

Diegobecker07 pushed a commit to Diegobecker07/leonida that referenced this pull request Nov 25, 2026
…e (RT-526)

A diagnostic for the retail boot (RT-5 follow-ups), off the hot path and with no behaviour change unless asked
for: LEONIDA_SKIP_ASSERTS=N (src/assert_skip.h, installed by main.cpp before any image code runs under
--init/--run): a vectored handler, added last, steps over up to N int3 (0xCC) at addresses in no host module and
logs each one as module+RVA (and as an int3_skipped trace event when --trace is open). After N it says so once
and the next int3 ends the run as before. An int3 in a host module, a breakpoint with no 0xCC at its address, or
a RIP that is neither at nor one past the 0xCC is passed on. Needs no --trace and no debugger.

Tests (synthetic, no game files): assert_skip_test (int3 in a VirtualAlloc'd page, the limit, a host-module int3,
a two-byte int 3, value parsing) and run_tiny_game_skip_asserts (two int3 in the mapped stand-in game, stepped
over end to end).

Carried over from old upstream PR 9961 (ProjectLeonida#228) without its caller logging for forwarded device slots, which the
carry-over of old PR 9990 (ProjectLeonida#1390) brings instead.

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

Copy link
Copy Markdown
Collaborator Author

Closing carried-over draft: carried over in #1395 (OLD-9961) and #1390 (OLD-9990).

@Andretuta Andretuta closed this Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants