foundry: Foundry crashes with `arithmetic operation overflow`
Component
Forge
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
forge 0.2.0 (70f4fb5 2022-11-02T00:05:06.592613Z)
What command(s) is the bug in?
forge test
Operating System
Linux
Describe the bug
Hello, after updating forge-std dependency foundry started crashing with arithmetic operation overflow error. The issue is occuring locally on my M1 Macbook as well as in a linux docker container in CI. Here is the code and here is the log of a failing CI pipeline.
Update
The bug is not related to forge-std (the forge-std update simply made it occur more frequently). The bug is caused by overflow in smart contract execution.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 29 (14 by maintainers)
I’ve narrowed this down to these lines
https://github.com/AztecProtocol/aztec-connect-bridges/blob/f8ef3f8dc5a3c21046d20fa235de6271586cb1a1/src/test/bridges/erc4626/ERC4626.t.sol#L56-L57
at least if I comment out the entire
testFullFlowtest and those two lines then the panic goes away.Hi @mattsse — wanted to share that I’m unfortunately running into a similar issue. As far as I can tell, if a test combines the following, it leads to intermittent crashing of foundry:
dealcheatcodeexpectRevertWhen I get a chance, I will try to create a small repro example!
Hello @mattsse, our CI is now passing without any crashes so you can probably close this issue. Thank you for fixing this 👍
@benesjan it appears either #3688 or #3687 has fixed that, couldn’t reproduce on master, but present on nightly
will land in nightly in a couple hours, sorry about these hiccups
thanks,
no fuzz test this time, makes it easier to debug, will have a closer look.
the randomness of this is likely related to the fuzz test function’s inputs.
Me guess at this point is, that the state changes inside the prank are picked up by the fuzzer (which looks at state) and perhaps the uint96 strategy has a problem with those values.
@mds1 it’s not caused by the update but it seems the update makes it more frequent. I think that the tests are simply failing with the overflow error and for some reason it causes forge to crash. Sometimes forge doesn’t crash and I see that the tests fail with the overflow error. I tried compiling an older forge version (from October 17) and the issue occurs there as well.