0

Getting this error which means I'm probably putting too much on the stack.

is it possible to find out the exact instruction that is causing this?

Or does this error mean that everything on my program is being put on the stack and changing a single anchor function/instruction won't change anything?

Error: Function _ZN112_$LT$solana_program..instruction..InstructionError$u20$as$u20$solana_frozen_abi..abi_example..AbiEnumVisitor$GT$13visit_for_abi17h14ef924a4ab59970E Stack offset of 4608 exceeded max offset of 4096 by 512 bytes, please minimize large stack variables

1 Answer 1

2

The function is given in the error message:

_ZN112_$LT$solana_program..instruction..InstructionError$u20$as$u20$solana_frozen_abi..abi_example..AbiEnumVisitor$GT$13visit_for_abi17h14ef924a4ab59970E

And if you run that through rustfilt to demangle it, you get:

$ rustfilt '_ZN112_$LT$solana_program..instruction..InstructionError$u20$as$u20$solana_frozen_abi..abi_example..AbiEnumVisitor$GT$13visit_for_abi17h14ef924a4ab59970E'
<solana_program::instruction::InstructionError as solana_frozen_abi::abi_example::AbiEnumVisitor>::visit_for_abi

So this is coming from the implementation of AbiEnumVisitor for InstructionError. If you dig into AbiEnumVisitor at https://github.com/anza-xyz/agave/tree/master/frozen-abi, you'll see that this only used at compile time, to make sure that the enum isn't changed (roughly). It is never actually called at runtime.

In the source code, you'll notice that this derive isn't done anymore for solana targets: https://github.com/anza-xyz/agave/blob/2e911559d047bcd16ce22f4d3cc4a8604b35bd66/sdk/program/src/instruction.rs#L31 -- so if you use a newer version of the crate, you won't get the error. Be sure to upgrade if you don't want to see the error, but it will never be called in your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.