-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Closed
Labels
Description
Description
Yul->Wasm translation produces for loops that repeat the initialization code in every iteration. The effect is an infinite loop.
From Yul code like this:
for { <init> } <condition> { <increment> }
{
<body>
}we get wasm like this:
(loop $loop_label
<init>
<condition>
<body>
<increment>
(br $loop_label)
)This is wrong because jumping to loop_label repeats the <init> block in each iteration.
Environment
- Compiler version:
develop(>= 0.6.10)
Steps to Reproduce
- Check out
evmc-vms-evm-ewasmbranch from Add support for ewasm evmc vm. #9143 which allows you to execute wasm tests on hera. - Build
soltest - Put this example in
test/libsolidity/semanticTests/tmp/test.solcontract test { function f(uint x) public pure returns(uint r) { for (uint i = 0; i < 5; i++) { for (uint j = 0; j < 5; j++) { x++; } } return x; } } // ==== // compileToEwasm: also // compileViaYul: true // ---- // f(uint256): 0 -> 0x19
- Run
soltest:soltest --run_test=semanticTests/tmp/* -- --vm <path-to-evmone>/libevmone.so --vm <path-to-hera>/libhera.so —evm-version=byzantium --no-smt --show-messages
- It hangs.
The test hangs.