Repository navigation
[AUTOMATED] fix(p3): keep a narrow load's width when it is read through a wider-typed pointer - #677
Merged
Merged
Conversation
…gh a wider-typed pointer RuleExpandLoad's truncation form accepted a loaded value whose type was still undefined; the SUBPIECE it left printed as a cast to int of the loaded width, so a zero-extended call argument read back sign-extended ((short)a0[0x1a] for movzwl 0x68(%rdi)). The form now declines an undefined value, which keeps the narrow load: *(unsigned short *)&a0[0x1a]. A value whose type is known signed or unsigned still takes the truncation form (declining those too would move kuna-tiedphitrim #13/#14, which are value-correct). Strict fix, no option. Round-trip regression test on a committed gcc -O2 fixture: the printed f is compiled and must hand sink 0x9abc. Spec 03 describes the decline. Extracted from the protoorder branch (PR #669), without any protoorder code. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
… over 12 and 46 binaries classify.py sorts each function whose decompile-all code differs between a main build and this branch; corpus-diff.txt holds the per-binary tables, the hand labels for the 8 rows the script leaves, and the arity invariants. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
…ch and speed measurements Speed, interleaved min-of-15 whole-binary decompile-all, main vs branch: fmt +2.5%, ls +0.4%, kmod +0.1%, bzip2 O0 +1.5%, find O2-noinline +0.8%. type_match over 444 slices (10,748 functions): 959 -> 959 perfect, 0 moved. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
mahaloz
added a commit
that referenced
this pull request
Sep 18, 2026
…fix now comes from main; fixture README rows; a lost-truncation main defect handed off Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
mahaloz
added a commit
that referenced
this pull request
Sep 18, 2026
…ly when every access agrees (+ #677 round trip under the flip, signfield fixture, probe) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
mahaloz
added a commit
that referenced
this pull request
Sep 18, 2026
…ly when every access agrees (+ #677 round trip under the flip, signfield fixture, probe) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG
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.
The problem
A narrow field that the binary zero-extends into a wider argument is printed as a signed cast of the wider element when the pointer it is read through is typed wider. Compiled, the printed C passes a different value than the binary does.
fdoesmovzwl 0x68(%rdi),%edi, sosinkgets 39612.(short)a0[0x1a]sign-extends: compile thisfandsinkgets 4294941372.The fix
RuleExpandLoadwidens a load to the element type of its pointer, then truncates the result. It no longer does this when the loaded value's type is still undefined. The load keeps its own width:sink(*(unsigned short *)&a0[0x1a]);.kuna-tiedphitrimdocs: build-plan for the infeasible-at-tier / non-ELF / huge-subsystem analyzers #13/Analysis-tier: AArch64 PLT import-name e2e (linked fixture) #14.The tests
a_zero_extended_narrow_load_round_trips_through_the_printed_c(decompile_all_cli.rs) decompiles the committed gcc -O2 fixtureexpandload_zext_x86_64, compiles the printedfand checks thatsinkreceives 0x9abc. It fails on main and passes here.(int)p[k]becomes*(unsigned int *)&p[k], sometimes with the temporary that holds it narrowed too.docs/features/expandload/corpus-diff.txtsorts them by class. Call arguments,variables[]rows and type_match (10,748 scored functions) are unchanged. Datatests 675/675 and stages match their baselines.🤖 Generated with Claude Code
https://claude.ai/code/session_01YFCA715QE6ZBSnTn7bwabG