-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assembly clearing local variable #13494
Comments
What do you mean by this? @wighawag |
Hm... first I thought, I can't reproduce it, but the following
i.e. the second event emission emits a zero address in the unoptimized via-IR run. Interestingly, though, the same happens when exchanging The legacy runs and optimized runs also seem fine... and the IR code looks rather innocent at least at a quick glance, though, so I'm expecting this to be some kind of false positive but it's suspicious that something similar seems to happen in our testing framework and with hardhat, so there's definitely cause to investigate this... |
if you uncomment the so not sure of the issue is that newContract got affected or as @ekpyron mention something else is happening, but there something going wrong here. |
Hi @wighawag, the test fails with Running your code on foundry though seems to work fine, with or without the
I also tested using the example payload that you are using in your tests. Could you please provide some more information about the bug? |
@r0qs are you using the geth node provided in the repo via docker-compose ? the run out of gas issue happen on hardhat, running against geth expose the issue and where if you uncomment the log1 it passes |
FYI the second creation failing with out-of-gas, resulting in |
@r0qs you might have forgotten that step if you used geth : I know this sounds crazy and you made me tripple check what I saw, but it really is happening, see CI action : https://github.com/bug-reproduction/solidity-assembly-variable-reset/runs/8231871860?check_suite_focus=true I add the example with the extra log1 and it passes |
@ekpyron compiling the code with solc and
Maybe something related with this regex and comments inside an assembly block: https://github.com/ethereum/solidity/blob/develop/libyul/AsmParser.cpp#L194 solc version: |
I didn't use the docker-compose. I'll take a look at it as well, thanks. I was trying to first investigate the contract. |
I updated the repo (https://github.com/bug-reproduction/solidity-assembly-variable-reset) to have hardhat test works too (works in the sense that the weird behavior is also shown)
|
I updated the test and now specify specific gas limit and it passes Probably the estimate_gas do not calculate enough for some reason. and when the log1 is added the estimate is correct for some reason Should have thought about that, I guess we can close the issue unless you want to keep for the segmentation fault you find |
Hi @wighawag thank you very much for confirming the gas issue. I will be closing the issue for now since your problem was solved, and it is unlikely that the compiler caused it. Still, I will further investigate your suspicion of the miscalculation of the gas estimation and the use of log1. |
Description
It seems in some conditions, assembly code is messing up with local variable even when it should not
What is even weirder, is that adding some extra code remove the issue.
Reproduction repo here :
https://github.com/bug-reproduction/solidity-assembly-variable-reset
Environment
Steps to Reproduce
The issue only arise when the input
data
is big enough, tested with 24000 bytessee repo for reproducing the bug : https://github.com/bug-reproduction/solidity-assembly-variable-reset
The text was updated successfully, but these errors were encountered: