mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6397 from ethereum/yulInterpreter-maxSteps
yulInterpreter: Add timeout based on the number of interpreted statem…
This commit is contained in:
commit
77b8b4874d
@ -24,6 +24,7 @@ void yulFuzzerUtil::interpret(ostream& _os, shared_ptr<yul::Block> _ast)
|
|||||||
{
|
{
|
||||||
InterpreterState state;
|
InterpreterState state;
|
||||||
state.maxTraceSize = 75;
|
state.maxTraceSize = 75;
|
||||||
|
state.maxSteps = 10000;
|
||||||
Interpreter interpreter(state);
|
Interpreter interpreter(state);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -128,6 +128,12 @@ void Interpreter::operator()(Continue const&)
|
|||||||
|
|
||||||
void Interpreter::operator()(Block const& _block)
|
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();
|
openScope();
|
||||||
// Register functions.
|
// Register functions.
|
||||||
for (auto const& statement: _block.statements)
|
for (auto const& statement: _block.statements)
|
||||||
|
@ -75,6 +75,8 @@ struct InterpreterState
|
|||||||
/// Memory size limit. Anything beyond this will still work, but it has
|
/// Memory size limit. Anything beyond this will still work, but it has
|
||||||
/// deterministic yet not necessarily consistent behaviour.
|
/// deterministic yet not necessarily consistent behaviour.
|
||||||
size_t maxMemSize = 0x200;
|
size_t maxMemSize = 0x200;
|
||||||
|
size_t maxSteps = 0;
|
||||||
|
size_t numSteps = 0;
|
||||||
LoopState loopState = LoopState::Default;
|
LoopState loopState = LoopState::Default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user