mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:00:52 +01:00
[PR #41] startup trace: a call through a null pointer names its caller (null_call_from) #94
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#94
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/41
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:old-pr/7189📝 Commits (3)
cd6277cstartup trace: a call through a null pointer names its caller4524c01registry: no module lookup for an address in the null paged077c5astartup trace: a null transfer is attributed to a call only when the call is proven📊 Changes
4 files changed (+170 additions, -4 deletions)
View changed files
📝
runtime/README.md(+1 -1)📝
runtime/shims/registry.cpp(+4 -1)📝
runtime/shims/startup_trace.h(+83 -2)📝
runtime/test/startup_trace_test.cpp(+82 -0)📄 Description
Original description (mentions and
#Nreferences are disabled; the numbers refer to the old repository):Claimed in the coordination issue: https://github.com/ItsNotRexed/Leonida/issues/7049#issuecomment-7106564862
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#6953fixes. 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
@Pipodi:#6953and the boot-chain measurements this was used against.@NiiRoZz:#7075/#7076, which got the run far enough to need it.@dadsmallbuk1: tested it on an RTX 5090 with a native MSVC build (ctest -R ^startup_trace$pass, the six new checks).@illusionart453-max: an independent native MSVC build and run (32/32).@JoaoPauluu: the Wine run that foundmodule_offset(0)naming the null page as the executable, and the guard now inregistry.cpp.@TheHoracio: tested on RX 7800 XT.@Jadiac5: tested on RX 9070 XT.@DeSunShine: tested on RTX 4090.@itaskaev2: tested on RTX 4080 SUPER.@SirKingg: an integration check with six other PRs' hunks in a Windows Sandbox, and the tail-jump case: a null tail jump pushes no return address, so the field named the wrong frame.@sds-228: the same finding in review, with the two ways out (verify the instruction, or narrow the field).d077c5a4cdoes both.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.