diff --git a/test/tools/ossfuzz/yulFuzzerCommon.cpp b/test/tools/ossfuzz/yulFuzzerCommon.cpp index 96c9c9de4..b989f3910 100644 --- a/test/tools/ossfuzz/yulFuzzerCommon.cpp +++ b/test/tools/ossfuzz/yulFuzzerCommon.cpp @@ -24,6 +24,7 @@ void yulFuzzerUtil::interpret(ostream& _os, shared_ptr _ast) { InterpreterState state; state.maxTraceSize = 75; + state.maxSteps = 10000; Interpreter interpreter(state); try { diff --git a/test/tools/yulInterpreter/Interpreter.cpp b/test/tools/yulInterpreter/Interpreter.cpp index e9b4dbd94..ebff8489c 100644 --- a/test/tools/yulInterpreter/Interpreter.cpp +++ b/test/tools/yulInterpreter/Interpreter.cpp @@ -128,6 +128,12 @@ void Interpreter::operator()(Continue const&) void Interpreter::operator()(Block const& _block) { + m_state.numSteps++; + if (m_state.maxSteps > 0 && m_state.numSteps >= m_state.maxSteps) + { + m_state.trace.emplace_back("Interpreter execution step limit reached."); + throw InterpreterTerminated(); + } openScope(); // Register functions. for (auto const& statement: _block.statements) diff --git a/test/tools/yulInterpreter/Interpreter.h b/test/tools/yulInterpreter/Interpreter.h index dbeb7f5a4..157cf1080 100644 --- a/test/tools/yulInterpreter/Interpreter.h +++ b/test/tools/yulInterpreter/Interpreter.h @@ -75,6 +75,8 @@ struct InterpreterState /// Memory size limit. Anything beyond this will still work, but it has /// deterministic yet not necessarily consistent behaviour. size_t maxMemSize = 0x200; + size_t maxSteps = 0; + size_t numSteps = 0; LoopState loopState = LoopState::Default; };