You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If instruction has some #[account] constraints with a lot of accounts being used and there is byte arrays or pubkeys in instruction parameters, then some random part inside them is overwritten with random bytes.
If you run anchor test, you can see, for example, the following:
In test address in parameters is Dcc6XavF27YRghRAbRz6nXdkPPCxFQn6QGARe3zNtDEL
In program log address is 11111111MTqikiemb67RkFxGXUHYRnutwFgf1dF9R
If i remove #[account] constraint from one of the accounts inside the instruction, params are becoming equal.
If i use less accounts, params are becoming equal also.
The text was updated successfully, but these errors were encountered:
serejkaaa512
changed the title
Instruction parameters are overwritten with random bytes, when instruction size is close to the limit and constraints being used
Instruction parameters are overwritten with random bytes, when instruction size is close to the limit and constraints are being used
Aug 24, 2024
Thanks for the report. This is a known issue and is being worked on. You're essentially going over the stack limit, but the compiler has a bug (as mentioned in #3060), and it doesn't always tell you that you've gone over the stack, resulting in undefined behavior (same as #3113 (comment)).
The compiler not telling you've gone over the stack should be fixed with solana v2, and we'll also have optimizations for our stack usage to fix this problem in the next version (see #3194).
Thanks for the answer here, I ran into the same problem. If i understand your answer correctly the compiler detecting this problem will not be fixed in anchor versions supporting solana versions lower than v2 right (although tools like LazyAccount will be added to mitigate this better)?
If so, I'd suggest keeping this issue open and only marking it as complete once anchor supports solana v2 to make it clearer that this is a known issue which currently isn't solved yet.
I'd suggest keeping this issue open and only marking it as complete once anchor supports solana v2 to make it clearer that this is a known issue which currently isn't solved yet.
This was closed because we have a bunch similar issues that are basically duplicate of #2955 (don't mind the completed flag).
We're also upgrading to Solana v2 (#3219), Solana v2 combined with #2939 mostly solves this issue, which will be included in the next version.
If instruction has some
#[account]
constraints with a lot of accounts being used and there is byte arrays or pubkeys in instruction parameters, then some random part inside them is overwritten with random bytes.I've made an example.
If you run
anchor test
, you can see, for example, the following:address
in parameters isDcc6XavF27YRghRAbRz6nXdkPPCxFQn6QGARe3zNtDEL
address
is11111111MTqikiemb67RkFxGXUHYRnutwFgf1dF9R
If i remove
#[account]
constraint from one of the accounts inside the instruction, params are becoming equal.If i use less accounts, params are becoming equal also.
Versions:
anchor-lang = "0.30.1"
solana-program = "1.18.22"
The text was updated successfully, but these errors were encountered: