Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing out-of-heap error due to large memory copy #445

Merged
merged 4 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Minimum distance requirements are now asserted for Keccak function calls. They assert that it's hard to generate two Keccak's that are less than 256 afar.
- Keccak concretization is now done only after all simplifications are performed. This helps with simplification pre-concretization
- Added an IllegalOverflow error in case the system tries to allocate a large amount of memory during
abstract gas execution but concrete running. In these cases, the interpreter can out-of-heap
as the only check is that the size allocated is less than $2**{64}$, but that is too large to fit in memory. Now,
we check more stringently, and still return an IllegalOverflow

## Added

Expand Down
8 changes: 7 additions & 1 deletion src/EVM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,13 @@ accessMemoryRange (Lit offs) (Lit sz) continue =
Just (offs64, sz64) ->
if offs64 + sz64 < sz64
then vmError IllegalOverflow
else accessUnboundedMemoryRange offs64 sz64 continue
-- we need to limit these to <256MB because otherwise we could run out of memory
-- in e.g. OpCalldatacopy and subsequent memory allocation when running with abstract gas.
-- In these cases, the system would try to allocate a large (but <2**64 bytes) memory
-- that leads to out-of-heap. Real-world scenarios cannot allocate 256MB of memory due to gas
else if offs64 >= 0x0fffffff || sz64 >= 0x0fffffff
then vmError IllegalOverflow
else accessUnboundedMemoryRange offs64 sz64 continue
-- we just ignore gas if we get symbolic inputs
accessMemoryRange _ _ continue = continue

Expand Down
Loading