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

Open
opened 2026-11-26 20:17:22 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/228
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9961


📝 Commits (1)

  • a75e325 runtime: LEONIDA_SKIP_ASSERTS and caller logging for forwarded device slots (RT-526)

📊 Changes

12 files changed (+541 additions, -9 deletions)

View changed files

📝 docs/boot.md (+6 -0)
📝 docs/d3d12_command_objects.md (+4 -1)
📝 runtime/CMakeLists.txt (+19 -0)
📝 runtime/README.md (+21 -2)
📝 runtime/shims/d3d12_xs_device.cpp (+37 -3)
📝 runtime/shims/d3d12_xs_device.h (+13 -0)
➕ runtime/src/assert_skip.h (+151 -0)
📝 runtime/src/main.cpp (+14 -0)
➕ runtime/test/assert_skip_test.cpp (+135 -0)
📝 runtime/test/fixtures/tiny_game.cpp (+22 -1)
📝 runtime/test/xs_proxy_mock_test.cpp (+117 -1)
📝 tools/boot_trace.py (+2 -1)

📄 Description

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 (e56d9795) 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 (867d922f), 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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/228 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9961` --- ### 📝 Commits (1) - [`a75e325`](https://github.com/ubiquitarianism/leonida/commit/a75e3253e855d07fdaa50f9bb618c32e8e70dc73) runtime: LEONIDA_SKIP_ASSERTS and caller logging for forwarded device slots (RT-526) ### 📊 Changes **12 files changed** (+541 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `docs/boot.md` (+6 -0) 📝 `docs/d3d12_command_objects.md` (+4 -1) 📝 `runtime/CMakeLists.txt` (+19 -0) 📝 `runtime/README.md` (+21 -2) 📝 `runtime/shims/d3d12_xs_device.cpp` (+37 -3) 📝 `runtime/shims/d3d12_xs_device.h` (+13 -0) ➕ `runtime/src/assert_skip.h` (+151 -0) 📝 `runtime/src/main.cpp` (+14 -0) ➕ `runtime/test/assert_skip_test.cpp` (+135 -0) 📝 `runtime/test/fixtures/tiny_game.cpp` (+22 -1) 📝 `runtime/test/xs_proxy_mock_test.cpp` (+117 -1) 📝 `tools/boot_trace.py` (+2 -1) </details> ### 📄 Description > 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` (e56d9795) 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_assert`s 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` (867d922f), 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 - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. The log lines shown are formats with placeholder offsets. - [x] 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](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#281
No description provided.