Repository navigation
Diagnostics: the return-address scan tests an image's code sections before VirtualQuery - #51
Merged
ThatRecompDev merged 1 commit intoNov 25, 2026
Conversation
…efore VirtualQuery With --watch-hang, every wait of the game records its caller frames. The scan behind that walks 64 KB of stack and called VirtualQuery for each value inside an image's range, and stacks hold many pointers into an image's data. In a managed profile of a world load, that was 66% of the shims' time on the game's threads, and the animation after the title screen stuttered with --watch-hang and not without it. A value now needs its six call bytes inside an executable section of the image, per its headers, before the readable-code check: data pointers are dropped without a system call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
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