Skip to content

Commit

Permalink
Merge pull request #445 from ethereum/fix-mem-out
Browse files Browse the repository at this point in the history
Fixing out-of-heap error due to large memory copy
  • Loading branch information
msooseth authored Feb 5, 2024
2 parents d5fd5bf + f6ff89b commit 63f32d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 63f32d0

Please sign in to comment.