-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Compiling 16 files with 0.7.6 CompilerError: Stack too deep when compiling inline assembly: Variable headStart is 2 slot(s) too deep inside the stack. Error HH600: Compilation failed #11638
Comments
Unfortunately, this is a known issue, and does not have a good fix. (We are working on a solution for upcoming solidity versions, but until then, sorry) Here are two suggestions that are not perfect, but might work
If you do the second option and it works, could you please follow up? |
@hrkrshnn It's kind of disappointing as I don't even have a large or complex contract. It's actually the code as above with some extra variables and functions "beside" that, so not even nested ... so I find it strange that the stack does not have 0 entries and can easily cope with it ... |
@SvenMeyer Could you post a minimal example with the stack too deep error? Perhaps we could help with a specific suggestion to fix it. BTW, the function |
Though there's a gotcha to watch out for if the actual struct is not the same as in the code above: a getter would skip any array fields within the struct. |
@hrkrshnn even without the I tried to come up with minimal version, that's the code above which I initally posted ... and that works. Hard to say what needs to be removed to just break it. The struct does not look too complicated (with 7 entries , 4 x 256 Bit words) to me as well and can't be reduced further. I invited you to my repo, just in case you want to have a look and may spot something at first sight ... I assume solc 0.8.x would not make a difference either ? |
@SvenMeyer You can try running with the latest release / develop. There were some minor changes in stack management that might help. |
:-( |
looks like with solc 0.8.4 and 0.8.6 I even get the error with https://github.com/polkastarter/fixed-swap-offchain-whitelist/tree/solc_0.8 |
@SvenMeyer In 0.8.0, |
This comment has been minimized.
This comment has been minimized.
Howdy all. Just wanted to let you know I did Option 2 and it fixed my problem. I was adding the diamond proxy contracts by @mudgen to my project (which is being compiled with 0.8.5). Even though his project was not getting the error, I was consistently getting the following in mine after adding his contracts:
The only difference was that @mudgen's
I personally had more going on:
I had previously discovered that setting
My only question now is what the effect of disabling the YUL optimizer will be. |
@cliffhall The ABI encoder v2 code for your contract would not be optimized. |
There's a bug that causes a stack overflow with the new YUL optimizer (ethereum/solidity#11638 (comment)) so we have to disable it
Had the same problemm with hardhat and larger number of structs. Putting |
I am getting the same issue with |
Unfortunately not, because at the stage where the problem happens the connection between your original source and the part that is being processed is pretty tenuous. The code is already after conversion to Yul, optimization (including inlining) and is being translated from Yul to EVM bytecode. The Yul source being compiled is just a big dump of code from your contract and any other contracts/functions it calls internally. The information about which parts of your original source this Yul code maps to is either unavailable or unreliable. We'd like to improve error reporting for that case (#12449) but there isn't much that can be done without guessing, and in the end focusing more on features that will make these errors happen less seems more productive. |
getting similar error on 0.8.13 |
@chee-chyuan Can you try setting |
thanks. compiling takes abit more time but that works |
also got in touch with etherscan & remix. hopefully they can support that soon |
I'm having this problem on Solidity v0.8.10 without using abiencoder v2.
How and where does one do this? |
im not sure if its available in v0.8.10. got to ask to team |
Ok... Regardless of version, how does one do that? |
Simply add
It's been available at least since 0.7.x, maybe even 0.6.x (you can check if your version supports it in |
Thanks for the info and resources! Very helpful. Unfortunately nothing helped. I've tried disabling the Yul optimizer, disabling the optimizer entirely, enabling viaIR, disabling peephole, enabling Yul stack allocation. In my case I'm getting only 1 slot too deep error. |
On 0.8.13? Can you post a new snippet that reproduces this? |
Turns out it was because my contract constructor had too many input arguments: contract Breaks {
constructor(string memory name_, string memory symbol_,
address _0,
address _1,
address _2,
address _3,
address _4,
address _5,
address _6,
address _7,
address _8,
address _9
) {}
} Removing Although oddly, if I add any more arguments to the constructor, the error still reports |
Thanks. So I just checked that with |
I have the same issue when my struct has too many variables. How can I turn this --via-ir on? I am using truffle. When I add this to truffle-config.js I have still the same issue. Maybe I add it in the wrong way? Here is my current config with this key `require('babel-register'); module.exports = { Thank you |
|
|
@cameel I added Any explanantion for that ?
Actually,
Still using
Is it actually (still) advised to specify |
We do lots of changes that affect the cost one way or another. Optimizations lower it, security-related changes often increase it so small differences like these are not uncommon. For example we recently merged #12647, which slightly increases bytecode size in most cases. Even if a change is an optimization that lowers the cost in most cases, there are pretty much always some corner cases where the cost goes up. For |
Enabling
|
@hrkrshnn I was getting
This error this was fixed by turning off yul optimiser |
@Alfa11917676 Was it with |
@cameel my code was a on-chain metadata generator with a lot of traits coming into actions. |
I mean, without seeing any code we can't really say anything just based on that error message. It simply says that the compiler ran out of available EVM slots but not why it happened. And before jumping into the code, we should make sure it's not one of the cases where the problem is still known to exist. I.e. are you using |
I've been hit with this issue too, I've been able to boil it down to this: struct Struct1 {
uint256 field;
}
struct Struct2 {
Struct1[] struct1;
}
contract Contract {
function foo(
uint256 arg1,
uint256 arg2,
uint256 arg3,
uint256 arg4,
Struct2[] memory struct2) external {}
} I'm using Solidity A WORKAROUND I've found for this particular case is to change |
I'm using solidity
|
@rkdud007 I think the coverage part is simply the tools not supporting via-ir. |
resolved my issue with viaIR to false for the first time but next time I got the error.
|
I had this issue today. Figured out a struct in my code was the culprit. Still unsure why or how the struct causes a Stack Too Deep error. Simply removed it from the code for now and am using raw value types only (uint, bool, etc). Any clarity why this error exists and why no line number is identified? Incredibly frustrating when working with a large codebase and many structs. |
Latest settings here worked for me
|
This issue has been marked as stale due to inactivity for the last 90 days. |
Hi everyone! This issue has been automatically closed due to inactivity. |
This works fine in Remix with/wo optimization using 0.7.6
However within my larger hardhat based project (just one contract with a few OpenZeppelin imports), as soon as I add
pragma abicoder v2;
I get this error message :hardhat.config.ts
The text was updated successfully, but these errors were encountered: