Skip to content

runtime: opt-in LEONIDA_SKIP_ASSERTS steps over the first N guest int3 asserts - #7204

Closed
Pipodi wants to merge 2 commits into
ProjectLeonida:mainfrom
Pipodi:rt-skip-guest-asserts
Closed

Pipodi wants to merge 2 commits into
ProjectLeonida:mainfrom
Pipodi:rt-skip-guest-asserts

Conversation

@Pipodi

@Pipodi Pipodi commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in #7049 as: #7049 (comment)

Depends on: none

What and why

LEONIDA_SKIP_ASSERTS=N (N > 0, off by default) makes gta6rt install a vectored exception handler that steps over
the first N int3 breakpoints raised by guest code. A breakpoint counts as guest code when its address is in no host
module (GetModuleHandleExW FROM_ADDRESS fails) and its byte is 0xCC; each skip is logged as
[rt] assert skipped: int3 in guest code at <module+RVA or address> (LEONIDA_SKIP_ASSERTS) and execution resumes at
the next byte. Host-module breakpoints, other exceptions and any int3 past the N-th continue the search unchanged.

A console devkit continues past a failed assert, and some of the title's asserts are tuning checks rather than
faults (docs/retail_boot_chain.md). With the switch a boot run can pass such a stop and show what comes next. It is
used on Pipodi:boot-integration (#6982) to pass two guest asserts.

The handler is runtime/src/guest_asserts.{h,cpp} (a small decision function plus the install call from
main.cpp), documented in runtime/README.md and noted in docs/retail_boot_chain.md. LEONIDA_SKIP_INT3 (with
--trace) stays as it was. This is separate from the merged #6937 LEONIDA_SKIP_INT3 because it works without
--trace, has a budget (N skips, then the exception goes on), and logs to stderr.

The claim that a devkit continues past failed asserts is stated as a hypothesis in the docs. The switch is a debugging
aid for the title's own asserts; it does not touch any protection or anti-debug check. Being a vectored handler it
runs before a guest __try that would catch the int3 itself.

Tested

RTX 4090 / 617.42, Windows 11, MSVC 14.44 (VS 2022 Build Tools), Ninja, RelWithDebInfo.

  • New guest_asserts_test (ctest guest_asserts): 19 checks, 0 failed. Synthetic decision cases (guest int3 skipped
    and counter decremented, host address not skipped, a byte other than 0xCC not skipped, exhausted counter, default
    off for unset, 0, negative and non-numeric values) and a real int3 round trip on VirtualAlloc'd executable
    memory (three skipped, the fourth reaches the caller).
  • ctest -R "guest_asserts|startup_trace|unimplemented_policy|loader": 7 of 7 passed.
  • python -m compileall -q make_game.py tools tests: clean.

AI-assisted: yes

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. (Not applicable: no translator change.)

🤖 Generated with Claude Code

Pipodi and others added 2 commits November 23, 2026 17:05
…3 asserts

A vectored handler, installed only when the variable is a positive count, resumes after an int3 at an address in no
host module and logs it. Off by default. Test: decision cases plus a real int3 round trip on VirtualAlloc memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt budget, hypothesis wording)

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

Copy link
Copy Markdown

Tested 85df099 on NVIDIA GeForce RTX 5090, driver 617.42, Windows 11 (26200), native MSVC 2022 RelWithDebInfo: pass, plus one retail run.

  • ctest -R guest_asserts: 1/1 pass.
  • Retail gta6rt --run with this branch alone (own 1.0.2.1 copy, LEONIDA_SKIP_ASSERTS=3, LEONIDA_D3D12=vulkan, a 120 s / 8 GB guard): the switch works. The log has [rt] assert skipped: int3 in guest code at game_scarlett_master.exe+…, the title resumes on the next byte, and nothing else is skipped. On this base the first guest assert is the 2 MiB-page commit's NULL check, stop 1 of docs/retail_boot_chain.md. Stepping over it ends 4 s in with an access violation writing 0x10 a few calls further on, through the NULL allocation. So that assert guards a real failure, not a tuning check, which may be worth a line next to the switch in the doc (skipping it only moves the crash).
  • Overlap: main already has LEONIDA_SKIP_INT3 (Startup trace: name failed guest file opens, and LEONIDA_SKIP_INT3 to follow a boot past soft asserts #6937, in startup_trace.h, docs/boot.md), which steps over every guest int3 (logged once per address) but only with --trace. This PR's switch is count-limited and works without --trace. If both are set, whichever vectored handler runs first takes the int3, so they don't double-skip, but docs/boot.md might name both and say when to use which.
  • Code read: host-module breakpoints and any exception other than EXCEPTION_BREAKPOINT pass through; the byte at Rip must be 0xCC and readable; off by default.

AI-assisted (Claude Code).

@myokex

myokex commented Nov 23, 2026

Copy link
Copy Markdown

Tested 85df09946 merged onto main 042c5f378 on Windows 11, Visual Studio 2022 (MSVC, RelWithDebInfo), CMake 4.4.4, Vulkan SDK 1.4.363.0, AMD Radeon RX 7800 XT (driver 32.0.32029.2010); synthetic tests only, no game files: pass.

Code read: the handler only acts on EXCEPTION_BREAKPOINT at an address outside every OS-loaded module whose byte is 0xCC and Rip equals the exception address, and only when LEONIDA_SKIP_ASSERTS is a positive number; off by default. AI-assisted (Claude Code).

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