Repository navigation
startup trace: a call through a null pointer names its caller (null_call_from) - #7189
rafaelpssz wants to merge 3 commits into
Conversation
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 <noreply@anthropic.com>
|
Tested cd6277c on NVIDIA GeForce RTX 5090, driver 617.42, Windows 11 (26200), Intel i9-13900K, native MSVC 2022 RelWithDebInfo: pass.
AI-assisted (Claude Code). |
|
@dadsmallbuk1 thanks for testing it on the 5090 with MSVC, added to Thanks. |
|
Independent native Windows/MSVC 19.44, SDK 10.0.26100, RelWithDebInfo at cd6277c: configured isolated CPU runtime, built and ran startup_trace_test: 32 checks, 0 failed. The null-call execute-fault, module+RVA caller, stack-start caller, and final-exit ordering checks passed. Build emitted MSB8029 for TEMP placement; no C++ source warning observed. No Vulkan/GPU coverage, no game files. AI-assisted (Codex). |
|
Tested Setup: CachyOS, Wine 11.21; clang-cl 23.1.5 + xwin 0.10.0 cross build (SDK 10.0.26100),
The null-call event the test writes (synthetic image) shows why:
A guard there fixes it. With this change on top of the PR, the test passes under Wine with - if (GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
+ if (address >= 0x10000 && GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,( Retail executable (my own 1.0.2.1 copy, Counts and error classes only from the retail run. AI-assisted (Claude Code). |
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 ProjectLeonida#7189. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@JoaoPauluu thanks, exact diagnosis. Your guard is in as 4524c01 ( |
|
Tested Merges into a branch with #4313/#7021/#7240 with a single trivial conflict in |
|
Tested 4524c01 on Windows 11, AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32029.2010: pass
AI-assisted (Claude Code). |
|
Tested
AI-assisted (Claude Code). |
|
Tested
|
|
Independent Windows Sandbox integration check of
Only counts, error classes and public slot names are shared; traces and analysis stay local. AI-assisted. |
|
One diagnostic edge case: a null tail jump does not push a return address. In a synthetic mapped function that tail-jumps through null, this handler reports the host function that entered the mapped function as Could this field be described as a possible return-frame origin rather than a proven null-call site, or otherwise guard against tail transfers? The retail slot-133 measurement is unaffected: its recovered return address was independently checked to follow a call. I also reported the finding on #9065. AI-assisted. |
sds-228
left a comment
There was a problem hiding this comment.
runtime/shims/startup_trace.h:194-200 treats [rsp] as a pushed return address for any access violation below the null-page limit. For call rax that is correct, but a tail jump through null pushes nothing, so null_call_from can name an unrelated frame; the test only covers the call form. Please either verify the instruction before attributing the caller, or narrow the field and documentation to what can be proven.
AI-assisted (OpenCode).
…call is proven Reported by SirKingg and sds-228 on ProjectLeonida#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 <noreply@anthropic.com>
|
@SirKingg @sds-228 you are right, and thanks for the synthetic repro. The handler took
Verify the instruction. The frame is Narrow the field. Everything else is One case still reads as a call: a tail jump through the same register the enclosing call went through (host The test now makes four transfers to 0: @TheHoracio @Jadiac5 @DeSunShine @itaskaev2 thanks for the runs on |
sds-228
left a comment
There was a problem hiding this comment.
The earlier concern about naming a tail jump as a call is resolved at this head: the handler now verifies the instruction before the return frame (an indirect call whose operand matches the faulting address) and reports tail transfers separately, with synthetic tests for register and memory calls and direct and indirect tail jumps. Approving. AI-assisted (OpenCode).
|
Tested Built So a fault at No Approved by @fortkolbast1. AI-assisted. |
Claimed in the coordination issue: #7049 (comment)
What and why
A call through a null pointer faults on the instruction fetch at address 0. Until now,
--tracelogged it as"at":"0x0","access":"execute","address":"0x0","stack":[].stack_fromstops at once becauseRipis 0, so the trace couldn't say who made the call. That's the most common shape of a boot stop right now: a console vtable slot past the end of a PC proxy's table, or an unset out-pointer the title calls through.A
callhas already pushed its return address. When an access violation is at an address in the first 64 KiB, the handler now:[rsp], asstack_fromalready does for a leaf function;module+RVA) with one of two fields.null_call_fromis used only when the call is proven. The instruction before the frame must be an indirect call (FF /2, register or memory), and its operand, evaluated with the registers of the fault, must be the faulting address. A fault on the fetch at a call's target comes before any instruction of the target runs, so those registers are still the call's own.null_transfer_returnis used otherwise: a direct call, an indirect call to some other address, or nothing recognizable. A tail jump through null pushes nothing, so the frame on the stack belongs to whoever entered the jumping function. The field says where that code would have returned to and makes no claim about who made the transfer.One case still reads as a call and is not: a tail jump through the same register the enclosing call went through. The README and the header say so.
Nothing else changes, and the handler still only records. If
[rsp]isn't readable, the event is logged as before.(The addresses above are made-up examples.) On the retail executable this turned the empty event into the caller. Its disassembly is a call through device vtable offset
0x428= slot 133, which is the stop #6953 fixes. It took one run instead of a debugger session (integration run in #7049).Changes
runtime/shims/startup_trace.h: the null-page case inlog_exception,faulting_call_ends_at(the check above), and the header's event examples.runtime/test/startup_trace_test.cpp: the synthetic image makes four transfers to address 0:call raxwithrax0:null_call_from, the instruction after the call, and the stack starts there;call [rip+slot]with a zero slot:null_call_fromtoo;jmp rcxwithrcx0, reached by a direct call:null_transfer_return, nonull_call_from;call raxto a real function:null_transfer_return, nonull_call_from.The existing in-image read fault gets neither field.
runtime/README.md: the field in the startup-trace event table.runtime/shims/registry.cpp:module_offsetdoes no module lookup for an address in the first 64 KiB. Under Wine,GetModuleHandleExW(FROM_ADDRESS, 0)answers with the executable, so a fault at 0 was namedexe+(0 - base)(JoaoPauluu's finding and fix).Tested
Windows 11 Pro 26200, clang-cl/xwin cross build (MSVC 14.44 headers), RelWithDebInfo:
startup_trace_test: 42 checks, 0 failed (d077c5a4c).d077c5a4c's change tostartup_trace.hreverted, 4 of the 42 fail: both jumps are attributed to the enclosing call, which is the misattribution the reviewers reported.startup_trace.h, 2 of the then 32 failed:null_call_from …andthe null call's stack starts at its caller.d077c5a4c: MSVC, and the retail executable (the earlier retail result below was for4524c0136; that call is an indirect call through a vtable slot, the form the new check accepts).gta6rtbuilds. With the change, a retail--run --traceon my own copy loggednull_call_fromfor the slot-133 call, as described above. No game data here.Thanks
ctest -R ^startup_trace$pass, the six new checks).module_offset(0)naming the null page as the executable, and the guard now inregistry.cpp.d077c5a4cdoes both.