Diagnostics: the return-address scan tests an image's code sections before VirtualQuery #51
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ThatRecompDev--five-star-recomp!51
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/51/head"
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?
@Sr-0w on GitHub · 2026-11-25 23:05 UTC · original
Sr-0w:diagnostics/wait-history-cheap→main· +69 −2 · 4 files · 1 commits · merged 2026-11-25 23:15 UTCWhat
ReturnAddresses.Scan, used by the--watch-hangwait-object history (#47) on every wait of the game, now drops a stack value unless its six call bytes lie in an executable section of the image. The test uses the section headers (LoadedImage.InCode) and runs before theVirtualQueryreadable-code check. Pointers into an image's data are rejected without a system call. Return addresses still get the same checks as before.Why
The scan walks up to 64 KB of stack and called
VirtualQueryfor each value inside an image's range. Game stacks hold many pointers into the image's data sections.In a managed profile (
--profile-managed, 30 s during a world load),WaitObjects.Waiting→ReturnAddresses.Scan→GameHangWatch.IsReadablewas 66% of the shims' samples on the game's threads.In game
All runs below are on an RX 7800 XT and were recorded:
--watch-hang --sample-threads 10: the short animation right after the "press A" title screen stutters, with frame drops and visible tearing in every recorded run.This change removes the scan's system calls on the wait path. The periodic stack captures of
--sample-threads(ThreadSnapshot, "stack capture stuck" about every 10 s) are a separate cost and are not touched here.Tests
Only_a_value_after_six_bytes_of_an_executable_section_is_checked_as_codetest, built on a two-section image.🤖 Generated with Claude Code
@ThatRecompDev on GitHub · 2026-11-25 23:15 UTC · original
nice find, 66% of the shims' time on the game's threads is a lot to lose to VirtualQuery on data pointers.
checking the section headers first is the right order, and the readable-code check still runs after it, so nothing gets less safe. the test with a two-section image covers the boundaries nicely.
merged into main (
0a2db0b), thanks!the --sample-threads stack captures you mention are on our list too, they're a separate cost from this