startup trace: a null transfer names its caller only when the call is proven (OLD-7189, carries #41) #1828

Open
github-bot wants to merge 4 commits from github-bot/gh-1828 into main AGit
Owner

@⁠potatoe0100 on GitHub · 2026-11-25 12:45 UTC · original
potatoe0100:carry/old-7189 → main · +170 −5 · 4 files · 4 commits · open

Claimed in the coordination issue as: OLD-7189 (#1608)

What and why

Carries forward old-pr/7189 (draft #41) by @⁠rafaelpssz, rebased on main 0d80bc5df with the author's three commits unchanged in content. An access violation at a null-page address is a fetch fault with nothing to unwind from, so the startup trace now names who got there: null_call_from when the instruction before the top-of-stack frame is an indirect call whose operand, with the fault's registers, is the faulting address, otherwise null_transfer_return (a tail jump). registry skips the module lookup below 0x10000, so a fault at 0 is 0x0 under Wine too. This helps world-start debugging, where null calls show up in the trace.

Rebase notes:

  • runtime/shims/startup_trace.h conflicted with main's register dump (regs), the tls_index0 event and dump_transient_pool. Kept all of main's, put the null-transfer handling after regs (on the same CONTEXT copy, so regs still shows the registers at the fault), and renumbered the example events in the header comment.
  • One extra commit of mine on top: startup_trace_test looked for null transfers with "at":"0x0" anywhere in the line, and main's runs entries also carry "at":"0x0", so the read fault inside the image matched as a fifth null transfer. It now matches "at":"0x0","access".

Supersedes draft #41 (its branch can be deleted once this lands).

Tested

VS 2022 (MSVC 19.44) RelWithDebInfo + Ninja, Vulkan SDK 1.4.363.0.

  • startup_trace_test: 43 checks, 0 failed (9 failed before the test fix above, all from the extra match).
  • Full ctest -j 6: 415 tests, all pass. xmem, xmem_* and xs_proxy_mock failed once while three other builds ran at the same time and pass 3 of 3 on their own.

GPUs tested: NVIDIA GeForce RTX 4060, driver 621.14, Windows 11 Pro 26H2 (build 26300)

AI-assisted: yes (Claude Code), by a non-developer tester.

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: no translator change)

🤖 Generated with Claude Code

**@⁠potatoe0100** on GitHub · 2026-11-25 12:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1828) `potatoe0100:carry/old-7189` → `main` · +170 −5 · 4 files · 4 commits · open Claimed in the coordination issue as: OLD-7189 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why Carries forward `old-pr/7189` (draft #41) by @⁠rafaelpssz, rebased on `main` `0d80bc5df` with the author's three commits unchanged in content. An access violation at a null-page address is a fetch fault with nothing to unwind from, so the startup trace now names who got there: `null_call_from` when the instruction before the top-of-stack frame is an indirect call whose operand, with the fault's registers, is the faulting address, otherwise `null_transfer_return` (a tail jump). `registry` skips the module lookup below 0x10000, so a fault at 0 is `0x0` under Wine too. This helps world-start debugging, where null calls show up in the trace. Rebase notes: - `runtime/shims/startup_trace.h` conflicted with `main`'s register dump (`regs`), the `tls_index0` event and `dump_transient_pool`. Kept all of `main`'s, put the null-transfer handling after `regs` (on the same `CONTEXT` copy, so `regs` still shows the registers at the fault), and renumbered the example events in the header comment. - One extra commit of mine on top: `startup_trace_test` looked for null transfers with `"at":"0x0"` anywhere in the line, and `main`'s `runs` entries also carry `"at":"0x0"`, so the read fault inside the image matched as a fifth null transfer. It now matches `"at":"0x0","access"`. Supersedes draft #41 (its branch can be deleted once this lands). ### Tested VS 2022 (MSVC 19.44) RelWithDebInfo + Ninja, Vulkan SDK 1.4.363.0. - `startup_trace_test`: 43 checks, 0 failed (9 failed before the test fix above, all from the extra match). - Full `ctest -j 6`: 415 tests, all pass. `xmem`, `xmem_*` and `xs_proxy_mock` failed once while three other builds ran at the same time and pass 3 of 3 on their own. GPUs tested: NVIDIA GeForce RTX 4060, driver 621.14, Windows 11 Pro 26H2 (build 26300) AI-assisted: yes (Claude Code), by a non-developer tester. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [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)
An access violation at an address in the first 64 KiB (a call through a null
or null-page pointer) used to be logged as "at":"0x0" with an empty stack:
the unwinder had no instruction to start from. The call has just pushed its
return address, so the trace now starts from that frame, as for a leaf
function, adds it as "null_call_from" (module+RVA) and walks the stack from
there.

startup_trace_test builds a leaf stub that does xor eax,eax / call rax and
checks the new field and the stack's first frame (2 of the 32 checks fail
without the change).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Under Wine, GetModuleHandleExW(FROM_ADDRESS, 0) answers with the
executable, so a fault at address 0 was named exe+(0 - base) instead of
0x0 and the null-call checks of startup_trace_test failed there (4 of 32).
No module can sit in the first 64 KiB; skip the lookup below 0x10000, as
JoaoPauluu proposed on #7189.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reported by SirKingg and sds-228 on #7189: the handler took the top of the stack as the return address of the
faulting call for any access violation in the null page. A tail jump through null pushes nothing, so the field
named the frame that had entered the jumping function, as if that call had gone to null.

The frame is now `null_call_from` only when the instruction before it is an indirect call (FF /2, register or
memory, with SIB, displacement and REX) whose operand, evaluated with the registers of the fault, is the faulting
address. A fault on the fetch at a call's target comes before any instruction of the target, so those registers are
the call's own. Otherwise (a direct call, an indirect call to some other address, nothing recognizable) the frame is
`null_transfer_return`: where that code would have returned to, with no claim about who made the transfer. `stack`
starts at that frame in both cases. One case still reads as a call: a tail jump through the same register the
enclosing call went through; README and the header say so.

startup_trace_test: four transfers to address 0 in a synthetic image (call rax, call [rip+slot], and a jmp rcx
reached by a direct call and by an indirect call to a real function). Red before the change at the four jump
checks (both jumps were attributed to the enclosing call), green after: 42 checks, 0 failed (clang-cl).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
main's access-violation event now carries "runs" entries whose "at" can also be
0x0, so the read fault inside the image matched too (5 instead of 4).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:07:27 +00:00
This pull request has changes conflicting with the target branch.
  • runtime/shims/startup_trace.h
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1828/head:github-bot/gh-1828'
git switch 'github-bot/gh-1828'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1828'
git switch 'github-bot/gh-1828'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1828'
git switch 'github-bot/gh-1828'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1828'
git switch 'main'
git merge --squash 'github-bot/gh-1828'
git switch 'main'
git merge --ff-only 'github-bot/gh-1828'
git switch 'main'
git merge 'github-bot/gh-1828'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.