Skip to content

runtime: a fatal exception names its place in the title: RVA, stack, registers (RT-FATAL-REPORT-RVA) - #2555

Open
kristofbarany wants to merge 1 commit into
ProjectLeonida:mainfrom
kristofbarany:leonida/fatal-report
Open

kristofbarany wants to merge 1 commit into
ProjectLeonida:mainfrom
kristofbarany:leonida/fatal-report

Conversation

@kristofbarany

Copy link
Copy Markdown

Claimed in the coordination issue as: RT-FATAL-REPORT-RVA (#1608 (comment))

What and why

gta6rt's fatal-exception filter printed only the exception code ([rt] unhandled exception 0x80000003: writing the session pipeline cache ...), so a title's soft assert (an int3 after a report call) could not be traced from the
log. It now also prints, once, before the pipeline cache is written:

[rt] fault at title +0x<rva>
[rt] title addresses on the stack (innermost first): +0x<rva> +0x<rva> ...
[rt] registers: rax=... rbx=... rcx=... rdx=... rsi=... rdi=... rbp=... rsp=... r8=... r9=... r12=... r13=... r14=... r15=...
[rt] rbx points at an object with vtable title +0x<rva>
  • The faulting address as an RVA of the title's image (or "outside the title image").
  • Up to 12 stack qwords that point into the image (likely return addresses), from the 512 above rsp.
  • The general registers, and the vtable RVA of an object in rbx when its first qword points into the image.
  • Reads go through ReadProcessMemory, so a bad stack pointer ends the walk instead of faulting again inside the
    handler (runtime/src/fatal_report.h). The image's base and size are recorded right after the title is loaded.

Found with it (the use that motivated it, see #2554): with the title's own upscaler forced on Series S, the title
stops about 30 s in at its out-of-memory report. The report gave the int3's RVA, the allocator call on the stack,
the request size in rdi (2.1 MiB) and the allocator object's vtable from rbx; reading that object's fields
then showed the full 1,277 MiB range.

Tested

  • fatal_report_test (new): a made-up exception record, context and stack over a stand-in image: the RVA, the image
    addresses in order with the limit, the registers, rbx's vtable, and a fault outside the image, an unknown image,
    an unreadable stack pointer and null exception pointers (no fault, a report). 7/7.
  • Full ctest on this branch (Windows 11, MSVC 2022, Ninja, RelWithDebInfo): 508 of 510 passed. The two failures,
    xbox_present (present failed (VkResult -11)) and d3d12_set_descriptor_heaps (recorded_commands check), are
    separate executables that do not build src/main.cpp or the new header, and fail the same way on the branch of
    runtime: LEONIDA_TITLE_PATCH, checked byte patches of the title from the environment (RT-TITLE-PATCH-ENV) #2554.
  • tests/test_docs_env_vars.py, test_ctest_registration.py, test_text_encoding.py: OK.
    scripts/check_no_game_data.py on the changed files: clean.
  • In the game: the same report code in a local build on an older runtime printed the lines above for the title's
    int3 (three runs, the same RVA each time). Not yet run in the game on this main.

GPUs tested: NVIDIA GeForce RTX 4070 12 GB, driver 621.40, Windows 11 (ctest)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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. (n/a)

…registers)

The fatal-exception filter printed only the code ("unhandled exception 0x80000003"), so a
title's soft assert (int3 after a report call) could not be traced from the log. It now
also prints the faulting address as an RVA of the title's image, the stack qwords that
point into the image (likely return addresses, innermost first), the general registers,
and the RVA of the vtable of an object in rbx. Reads go through ReadProcessMemory, so a
bad stack pointer ends the walk instead of faulting inside the handler
(runtime/src/fatal_report.h).

Found with it: the title's out-of-memory int3 when its own upscaler is forced on Series S
(the allocation size in rdi, the allocator's vtable from rbx).

Test: fatal_report_test (made-up exception record, context and stack over a stand-in image).

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

Copy link
Copy Markdown
Contributor

#2555 | head db0ecba | ctest -C RelWithDebInfo -R "^fatal_report$" (MSVC RelWithDebInfo; gta6rt also built) | red: n/a, the test includes the new src/fatal_report.h, so on main it does not compile (new diagnostic, not a fix of something main gets wrong) | green: main 02f71cc merged into the head, 7 checks, 0 failures, 1/1 passed | full suite: not run (a game boot was using the machine) | Windows 11, RTX 4070 SUPER, NVIDIA 621.01, Python 3.14 | AI-assisted: yes, Claude Code

@lixonik lixonik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the diff and tested merged onto main (493867366) with Ninja Release (MSVC).

Using ReadProcessMemory in rt::fatal_report::describe keeps the fatal-exception diagnostic safe against bad stack/object pointers, and the RVA/stack/register/vtable formatting and unit tests are clean.

Tests run

  • ctest --output-on-failure -R "^fatal_report$": 1/1 passed (fatal_report 0.02 s).
  • python -m unittest tests/test_ctest_registration.py: 7/7 passed (1.01 s).

AI-assisted (Antigravity, Gemini).

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.

3 participants