ethereum / aleth

Aleth – Ethereum C++ client, tools and libraries
GNU General Public License v3.0
3.96k stars 2.18k forks source link

The process aleth-vm throws an OutofMemoryError when it detect an "infinite loop" #5908

Open BattleBird opened 4 years ago

BattleBird commented 4 years ago

aleth version: 1.8.0 Operating system: Linux Installation: built from source

when I use the binary aleth-vm to run the following code, the following bytecode contains an "infinite loop", it will not print trace information and terminate the operation correctly until the gas limit is used up. ./aleth-vm_1.8.0 stats --code 608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063f8a8fd6d146044575b600080fd5b348015604f57600080fd5b506056606c565b6040518082815260200191505060405180910390f35b600080600190505b600581101560745760005481600054020160008190555080806001019150506074565b600054915050905600a165627a7a7230582010c05846ebb8bfc4e2e4c1d67c00000000000000008ae603dce419deaac37d13cb56c3c43a1bc2950029 --mnemonics --input f8a8fd6d The corresponding control flow graph is as follow, we can observe an infinite loop in block 0x74 abnormal_memory_TestLoop The corresponding set of opcode sequences is as follow, opcode_sequences

However, when I use the binary aleth-vm to run the following code, the following bytecode also contains an "infinite loop", it will continue to occupy CPU resources until the system kills the whole process. In addition, aleth throws OutOfMemoryError when it crashes.

./aleth-vm_1.8.0 stats --code 608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063f8a8fd6d146044575b600080fd5b348015604f57600080fd5b506056606c565b6040518082815260200191505060405180910390f35b600080600190505b6005811015604f5760005481600054020160008190555080806001019150506074575b600054915050905600a165627a7a7230582010c05846ebb8bfc4e2e4c1d67c00000000000000008ae603dce419deaac37d13cb56c3c43a1bc2950029 --mnemonics --input f8a8fd6d The corresponding control flow graph is as follow, we can observe an infinite loop in blocks 0x4f, 0x6c, 0x74. abnormal_storage_TestLoop The corresponding opcode sequences is as follow, storage_opcode_sequences

We provide enough gas limit when run two piece of bytecode both contain an infinite loop, but aleth run normally for one and throws OutOfMemoryErrors for another one. This corner cases may expose a bug in aleth's EVM implementation.

pepo939393 commented 3 years ago

Hello. Nice to meet you. I would like to work on this issue.

BattleBird commented 3 years ago

Hello. Nice to meet you. I would like to work on this issue.

Fine. Please keep track of the progress and keep in touch with me. Thanks very much:)

pepo939393 commented 3 years ago

Thank you too :) I will inform you about my progress in the short time.