Diagnostics: the return-address scan reads call bytes only from readable code #48
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!48
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/48/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 17:36 UTC · original
Sr-0w:diagnostics/return-address-scan-executable→main· +29 −12 · 5 files · 1 commits · merged 2026-11-25 22:11 UTCRebased on main's fix (
98d9727) and reduced to the protection mask, as asked:CallBytesReadablerequires the call bytes' page to be committed readable code:PAGE_EXECUTE_READ,PAGE_EXECUTE_READWRITEorPAGE_EXECUTE_WRITECOPY.PAGE_EXECUTEalone is refused, since execute-only sections fault on read.GameHangWatch.IsReadabletakes an optional mask of accepted protections.Win32ConstantsgainsPageExecuteWriteCopy(0x80).Tests:
WaitObjectsTests12/12.docs/debugging.mdupdated.🤖 Generated with Claude Code
@ThatRecompDev on GitHub · 2026-11-25 19:08 UTC · original · edited 2026-11-25 19:09 UTC
hey, thanks for this!
main picked up a fix for the same crash last night (
98d9727). it queries the page of the 6 call bytes on every scan, so this conflicts in ReturnAddresses now.i'd rather not cache the ranges per image though. pages inside an image can get decommitted later, and then the cache says readable when it isn't, which is the exact fault we're dodging.
the part of yours i really like is requiring a readable execute protection. main's IsReadable lets PAGE_EXECUTE through, and we do map execute-only sections that way.
could you rebase and turn this into just that mask inside CallBytesReadable (no cache)? maybe also reuse Win32Constants for commit/guard and add a named const for 0x80. happy to merge that
@Sr-0w on GitHub · 2026-11-25 21:15 UTC · original
Done: rebased on
98d9727and reduced to the readable-code mask insideCallBytesReadable, with no cache. It reuses Win32Constants (commit, guard, and a newPageExecuteWriteCopy= 0x80). The test now covers execute-only and read-write pages, which are refused.@Sr-0w on GitHub · 2026-11-25 21:58 UTC · original
In game: without this fix, a run crashed the .NET host with an AccessViolation in the return-address scan, which read an unmapped page of an image. With it, the next run went on to about 375 s, where the hang watch could name the stalled job (fixed by #49). Since then, runs reach the opening cinematic and last the full 600 s.
@ThatRecompDev on GitHub · 2026-11-25 22:11 UTC · original
thanks for turning this around so fast!
rebased onto
98d9727and keeping the readable-execute mask inside CallBytesReadable is exactly what i was after, the rest of IsReadable stays the same.nice touch naming 0x80 in Win32Constants and making the test a theory over the page protections, that covers the execute-only case nicely.
merged 👍