mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
yulInterpreter: More fine-grained exception handling
This commit is contained in:
@@ -76,9 +76,26 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
|
||||
|
||||
ostringstream os1;
|
||||
ostringstream os2;
|
||||
yulFuzzerUtil::interpret(os1, stack.parserResult()->code);
|
||||
try
|
||||
{
|
||||
yulFuzzerUtil::interpret(os1, stack.parserResult()->code);
|
||||
}
|
||||
catch (yul::test::StepLimitReached const&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
catch (yul::test::InterpreterTerminatedGeneric const&)
|
||||
{
|
||||
}
|
||||
|
||||
stack.optimize();
|
||||
yulFuzzerUtil::interpret(os2, stack.parserResult()->code);
|
||||
try
|
||||
{
|
||||
yulFuzzerUtil::interpret(os2, stack.parserResult()->code);
|
||||
}
|
||||
catch (yul::test::InterpreterTerminatedGeneric const&)
|
||||
{
|
||||
}
|
||||
|
||||
bool isTraceEq = (os1.str() == os2.str());
|
||||
yulAssert(isTraceEq, "Interpreted traces for optimized and unoptimized code differ.");
|
||||
|
||||
@@ -24,17 +24,10 @@ void yulFuzzerUtil::interpret(ostream& _os, shared_ptr<yul::Block> _ast)
|
||||
{
|
||||
InterpreterState state;
|
||||
state.maxTraceSize = 75;
|
||||
state.maxSteps = 10000;
|
||||
state.maxSteps = 100;
|
||||
Interpreter interpreter(state);
|
||||
try
|
||||
{
|
||||
interpreter(*_ast);
|
||||
}
|
||||
catch (InterpreterTerminated const&)
|
||||
{
|
||||
}
|
||||
|
||||
interpreter(*_ast);
|
||||
_os << "Trace:" << endl;
|
||||
for (auto const& line: interpreter.trace())
|
||||
_os << " " << line << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,9 +72,26 @@ DEFINE_PROTO_FUZZER(Function const& _input)
|
||||
|
||||
ostringstream os1;
|
||||
ostringstream os2;
|
||||
yulFuzzerUtil::interpret(os1, stack.parserResult()->code);
|
||||
try
|
||||
{
|
||||
yulFuzzerUtil::interpret(os1, stack.parserResult()->code);
|
||||
}
|
||||
catch (yul::test::StepLimitReached const&)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (yul::test::InterpreterTerminatedGeneric const&)
|
||||
{
|
||||
}
|
||||
|
||||
stack.optimize();
|
||||
yulFuzzerUtil::interpret(os2, stack.parserResult()->code);
|
||||
try
|
||||
{
|
||||
yulFuzzerUtil::interpret(os2, stack.parserResult()->code);
|
||||
}
|
||||
catch (yul::test::InterpreterTerminatedGeneric const&)
|
||||
{
|
||||
}
|
||||
|
||||
bool isTraceEq = (os1.str() == os2.str());
|
||||
yulAssert(isTraceEq, "Interpreted traces for optimized and unoptimized code differ.");
|
||||
|
||||
Reference in New Issue
Block a user