Merge pull request #6491 from ethereum/increase-maxSteps-for-opt-yul

Increase upper bound for number of interpreted steps for optimized code
This commit is contained in:
Daniel Kirchner 2019-04-12 12:34:47 +02:00 committed by GitHub
commit a4fbb06c2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 8 deletions

View File

@ -78,7 +78,10 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
ostringstream os2;
try
{
yulFuzzerUtil::interpret(os1, stack.parserResult()->code);
yulFuzzerUtil::interpret(
os1,
stack.parserResult()->code
);
}
catch (yul::test::StepLimitReached const&)
{
@ -91,7 +94,11 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
stack.optimize();
try
{
yulFuzzerUtil::interpret(os2, stack.parserResult()->code);
yulFuzzerUtil::interpret(
os2,
stack.parserResult()->code,
(yul::test::yul_fuzzer::yulFuzzerUtil::maxSteps * 1.5)
);
}
catch (yul::test::InterpreterTerminatedGeneric const&)
{

View File

@ -20,11 +20,18 @@ using namespace std;
using namespace yul;
using namespace yul::test::yul_fuzzer;
void yulFuzzerUtil::interpret(ostream& _os, shared_ptr<yul::Block> _ast)
void yulFuzzerUtil::interpret(
ostream& _os,
shared_ptr<yul::Block> _ast,
size_t _maxSteps,
size_t _maxTraceSize,
size_t _maxMemory
)
{
InterpreterState state;
state.maxTraceSize = 75;
state.maxSteps = 100;
state.maxTraceSize = _maxTraceSize;
state.maxSteps = _maxSteps;
state.maxMemSize = _maxMemory;
Interpreter interpreter(state);
interpreter(*_ast);
_os << "Trace:" << endl;

View File

@ -24,7 +24,16 @@ namespace yul_fuzzer
{
struct yulFuzzerUtil
{
static void interpret(std::ostream& _os, std::shared_ptr<yul::Block> _ast);
static void interpret(
std::ostream& _os,
std::shared_ptr<yul::Block> _ast,
size_t _maxSteps = maxSteps,
size_t _maxTraceSize = maxTraceSize,
size_t _maxMemory = maxMemory
);
static size_t constexpr maxSteps = 100;
static size_t constexpr maxTraceSize = 75;
static size_t constexpr maxMemory = 0x200;
};
}
}

View File

@ -74,7 +74,10 @@ DEFINE_PROTO_FUZZER(Function const& _input)
ostringstream os2;
try
{
yulFuzzerUtil::interpret(os1, stack.parserResult()->code);
yulFuzzerUtil::interpret(
os1,
stack.parserResult()->code
);
}
catch (yul::test::StepLimitReached const&)
{
@ -87,7 +90,10 @@ DEFINE_PROTO_FUZZER(Function const& _input)
stack.optimize();
try
{
yulFuzzerUtil::interpret(os2, stack.parserResult()->code);
yulFuzzerUtil::interpret(os2,
stack.parserResult()->code,
(yul::test::yul_fuzzer::yulFuzzerUtil::maxSteps * 1.5)
);
}
catch (yul::test::InterpreterTerminatedGeneric const&)
{