Merge pull request #6654 from ethereum/fix-yulinterpreter-nested-for-loop-bug

[Yul] Reset loop state (to default) before interpreting for loop's post block
This commit is contained in:
chriseth 2019-05-06 11:21:12 +02:00 committed by GitHub
commit 35677019a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,37 @@
{
{
let a := foo_0(calldataload(0))
sstore(0, a)
}
function foo_0(x) -> y
{
mstore8(1, 1)
for {
}
slt(1, keccak256(1, msize()))
{
let x_1 := foo_0(x)
}
{
continue
}
}
}
// ----
// Trace:
// MSTORE_AT_SIZE(1, 1) [0101]
// MSIZE()
// MLOAD_FROM_SIZE(1, 32)
// MSTORE_AT_SIZE(1, 1) [0101]
// MSIZE()
// MLOAD_FROM_SIZE(1, 64)
// MSIZE()
// MLOAD_FROM_SIZE(1, 96)
// SSTORE(0, 0)
// Memory dump:
// 0: 0001000000000000000000000000000000000000000000000000000000000000
// 20: 0000000000000000000000000000000000000000000000000000000000000000
// 40: 0000000000000000000000000000000000000000000000000000000000000000
// 60: 0000000000000000000000000000000000000000000000000000000000000000
// Storage dump:
// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000000

View File

@ -110,6 +110,7 @@ void Interpreter::operator()(ForLoop const& _forLoop)
if (m_state.loopState == LoopState::Break) if (m_state.loopState == LoopState::Break)
break; break;
m_state.loopState = LoopState::Default;
(*this)(_forLoop.post); (*this)(_forLoop.post);
} }
m_state.loopState = LoopState::Default; m_state.loopState = LoopState::Default;