diff --git a/lib/evmone/baseline.cpp b/lib/evmone/baseline.cpp index 47a7ed4332..9906ef6367 100644 --- a/lib/evmone/baseline.cpp +++ b/lib/evmone/baseline.cpp @@ -104,20 +104,28 @@ inline evmc_status_code check_requirements(const char* const* instruction_names, template evmc_result execute(const VM& vm, ExecutionState& state, const CodeAnalysis& analysis) noexcept { + // state.code = {analysis.padded_code.get(), analysis.code_size}; + + const auto* const code = analysis.padded_code.get(); + auto* tracer = vm.get_tracer(); if constexpr (TracingEnabled) - tracer->notify_execution_start(state.rev, *state.msg, state.code); + tracer->notify_execution_start(state.rev, *state.msg, code); const auto rev = state.rev; const auto instruction_names = evmc_get_instruction_names_table(rev); const auto instruction_metrics = evmc_get_instruction_metrics_table(rev); - const auto* pc = analysis.padded_code.get(); + const auto* pc = code; while (true) // Guaranteed to terminate because code must end with STOP. { if constexpr (TracingEnabled) - tracer->notify_instruction_start(static_cast(pc - code)); + { + const auto offset = static_cast(pc - code); + if (offset < analysis.code_size) // Skip STOP from code padding. + tracer->notify_instruction_start(offset); + } const auto op = *pc; const auto status = check_requirements(instruction_names, instruction_metrics, state, op); @@ -402,7 +410,7 @@ evmc_result execute(const VM& vm, ExecutionState& state, const CodeAnalysis& ana continue; case OP_PC: - state.stack.push(pc - analysis.padded_code.get()); + state.stack.push(pc - code); break; case OP_MSIZE: msize(state);