-
Notifications
You must be signed in to change notification settings - Fork 6k
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
"Stack too deep" in hardhat coverage
: YulException: Variable var_amount_1673 is 1 slot(s) too deep inside the stack
#13938
Comments
Unfortunately, there's no straightforward way. In the codegen, where the error is detected it is unfortunately a bit too late for the compiler to give a good suggestion (#12449). The go to way to do this is to revert back to the last working version of your code and readd changes one by one to see what triggered it. Then, if you're still getting it with via-IR and optimizer enabled, create a repro like #13906 (comment) and we'll try to fix it. |
@cameel is there any chance to fix compiler to provide additional information? |
For the legacy codegen, probably not. We might try some ideas as a part of #12449 but ultimately the problem boils down to the fact that in the codegen we're no longer dealing with the original source and very often it's hard to tell what in that source triggered it. For example the problem often occurs in the ABI encoding code generated in Yul by the compiler and not directly in your own code. Our plan (and it's actually something we're committed to solving in Q2: #13721) is to address this in the new codegen to the point that having to debug this is very rare and basically a non-issue. |
@cameel I thought we're using new codegen, since we are using via-ir flag. |
Is this the config file used by that build? I don't see the flag there. But, honestly, I assumed that you're not using because the error message tells you to. I'm actually not sure if that message has it hard-coded or if it actually checks :) If you are using it, then disregard that. But anyway, giving you the right location is hard in either case. Maybe with viaIR it's slightly easier because if it happens in your code maybe we'd be able to give you the Yul function name that you might be able to map to the Solidity function it was compiled from. Still, the main objective for now is to make this error rare in the first place. |
@cameel different branch This is happening in the PR: 1inch/limit-order-protocol#185 |
@k06a I tried to reproduce the "stack too deep" on that branch and I couldn't, even after trying various earlier commits or commenting out the blocks marked as "stack too deep". Then I noticed that in your CI it only failed on Looks like |
hardhat coverage
: YulException: Variable var_amount_1673 is 1 slot(s) too deep inside the stack
@cameel thank you, seems like you found and resolved an issue we were struggling last months! |
Great! In that case I'm closing the issue, since this was was actually caused by running with optimizer disabled, even if indirectly :) Please do report it if you run into it with optimizer enabled. |
@cameel I faced this issue again: https://github.com/1inch/limit-order-protocol/actions/runs/4123970772/jobs/7122647334 In this branch: 1inch/limit-order-protocol#204
|
The error message indicates that stack-to-memory wasn't possible due to non-memory-safe assembly somewhere (potentially in some imported library only): |
@ekpyron I am almost sure all out assembly is covered with |
I can't understand why |
Hm, ok, yeah, that's true... but yeah - I don't know myself precisely what those coverage builds really do, I can only explain what the compiler says there :-). |
Description
How to understand in which file and line the following error occurred?
https://github.com/1inch/limit-order-protocol/actions/runs/4105345200/jobs/7082068963
Environment
Steps to Reproduce
The text was updated successfully, but these errors were encountered: