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

baseline: Fix incorrect exit after invalid jump #370

Merged
merged 3 commits into from
Aug 3, 2021
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog],
and this project adheres to [Semantic Versioning].


## [0.8.1] — unreleased

### Fixed

- baseline: Fix incorrect exit after invalid jump.
[#370](https://github.com/ethereum/evmone/pull/370)


## [0.8.0] — 2021-07-01

## Added
Expand Down Expand Up @@ -265,6 +273,7 @@ It delivers fully-compatible and high-speed EVM implementation.
- The [intx 0.2.0](https://github.com/chfast/intx/releases/tag/v0.2.0) library is used for 256-bit precision arithmetic.


[0.8.1]: https://github.com/ethereum/evmone/compare/v0.8.0..release/v0.8.0
[0.8.0]: https://github.com/ethereum/evmone/releases/tag/v0.8.0
[0.7.0]: https://github.com/ethereum/evmone/releases/tag/v0.7.0
[0.6.0]: https://github.com/ethereum/evmone/releases/tag/v0.6.0
Expand Down
17 changes: 17 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,22 @@ jobs:
- upload_coverage:
flags: unittests

gcc-latest-memcheck:
executor: linux-gcc-latest
environment:
BUILD_TYPE: Debug
CMAKE_OPTIONS: -DCMAKE_CXX_FLAGS=-O1
steps:
- build
- test
- run:
name: "Install valgrind"
command: sudo apt-get -q update && sudo apt-get -qy install --no-install-recommends valgrind
- run:
name: "memcheck"
working_directory: ~/build
command: valgrind --vgdb=no --error-exitcode=99 bin/evmone-unittests

gcc-32bit:
docker:
- image: ethereum/cpp-build-env:15-gcc-10-multilib
Expand Down Expand Up @@ -370,6 +386,7 @@ workflows:
- consensus-tests
- gcc-min
- gcc-latest-coverage
- gcc-latest-memcheck
- clang-latest-ubsan
- clang-latest-coverage
- macos-asan
Expand Down
3 changes: 2 additions & 1 deletion lib/evmone/baseline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ CodeAnalysis analyze(const uint8_t* code, size_t code_size)
// Using "raw" new operator instead of std::make_unique() to get uninitialized array.
std::unique_ptr<uint8_t[]> padded_code{new uint8_t[i + 1]}; // +1 for the final STOP.
std::copy_n(code, code_size, padded_code.get());
padded_code[i] = OP_STOP; // Set final STOP at the code end.
padded_code[code_size] = OP_STOP; // Used to terminate invalid jumps, see op_jump().
padded_code[i] = OP_STOP; // Set final STOP at the code end - guarantees loop termination.

// TODO: Using fixed-size padding of 33, the padded code buffer and jumpdest bitmap can be
// created with single allocation.
Expand Down
12 changes: 12 additions & 0 deletions test/unittests/evm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,18 @@ TEST_P(evm, jump_over_jumpdest)
EXPECT_GAS_USED(EVMC_SUCCESS, 3 + 8 + 1);
}

TEST_P(evm, jump_to_missing_push_data)
{
execute(push(5) + OP_JUMP + OP_PUSH1);
EXPECT_STATUS(EVMC_BAD_JUMP_DESTINATION);
}

TEST_P(evm, jump_to_missing_push_data2)
{
execute(push(6) + OP_JUMP + OP_PUSH2 + "ef");
EXPECT_STATUS(EVMC_BAD_JUMP_DESTINATION);
}

TEST_P(evm, pc_sum)
{
const auto code = 4 * OP_PC + 3 * OP_ADD + ret_top();
Expand Down