Conversation
`loop_counter_ascends` accepted `post` yielding the counter plus any addend, so `add(p, not(31))` (solc's optimized `sub(pointer, 0x20)`) kept its seed as a lower bound. A counter that did not ascend got the lower bound 0, so `add(0x80, counter)` got the lower bound `0x80`, although a counter counting down from 0 wraps to 2^256 − 0x20 and the sum then wraps to `0x60` and `0x40`. `shl`, `sub` and all other operations gave no lower bound, so a store or copy length through them never marked the free memory pointer unbounded. A pointer advanced in the loop body, as in solc's storage array copy loop, counted as not ascending and cost the range proof. A counter now only ascends when the body's yield, every `continue` and `post` hand it on unchanged or plus a static step, and otherwise has no lower bound. `OffsetInfo::iteration_range` replaces `lower_bound`. It keeps a lower bound through `add`, `mul` and `shl` by a static shift only while the result fits 256 bits, and gives every other operation on literals and loop counters none, so a store or copy through such a value sets `fmp_could_be_unbounded`, also for a destination that `is_free_pointer_relative` accepts. Post inputs and loop outputs get ranges too, nested loops' `break`and `continue` no longer count for the outer loop, and the `Shl` arm is corrected to read the shift from `lhs`.
Fuzzy dedup turns the literal offsets of `Scratch` stores into a parameter and keeps the tag, but `Scratch` only says the store starts below `0x40`. A word stored at `0x3f` still covers `[0x40, 0x5e]`. The heap analysis ignored the tag, so after the merged helper overwrote the pointer word, the range proof truncated the pointer read. A full-word `MStore` with a non-static offset tagged `Scratch` now sets `fmp_could_be_unbounded`.
This branch has not been deployed
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.
Some fixes for addressing this PR comment and this PR comment.