Skip to content

anchor b no longer warns about the Frame Stack limit overflow in v0.31.0 #3633

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

Closed
IaroslavMazur opened this issue Mar 31, 2025 · 2 comments
Closed

Comments

@IaroslavMazur
Copy link

I’m observing a regression in v0.31.0 where anchor b no longer emits warnings when the instruction context exceeds the frame stack limit. Previously, a warning was printed when such an overflow was detected.

For example, consider the following instruction context, which is guaranteed to cause an overflow in the frame stack. However, running anchor b on a program containing this context produces no warning:

#[derive(Accounts)]
pub struct Initialize<'info> {
    #[account(mut)]
    pub signer: Signer<'info>,

    #[account(
        init,
        payer = signer,
        seeds = [b"random"],
        space = 8 + RandomAccount::INIT_SPACE,
        bump
    )]
    pub random_account_1: Box<Account<'info, RandomAccount>>,

    #[account(
        init,
        payer = signer,
        seeds = [b"random"],
        space = 8 + RandomAccount::INIT_SPACE,
        bump
    )]
    pub random_account_2: Box<Account<'info, RandomAccount>>,

    #[account(
        init,
        payer = signer,
        seeds = [b"random"],
        space = 8 + RandomAccount::INIT_SPACE,
        bump
    )]
    pub random_account_3: Box<Account<'info, RandomAccount>>,

    #[account(
        init,
        payer = signer,
        seeds = [b"random"],
        space = 8 + RandomAccount::INIT_SPACE,
        bump
    )]
    pub random_account_4: Box<Account<'info, RandomAccount>>,

    #[account(
        init,
        payer = signer,
        seeds = [b"random"],
        space = 8 + RandomAccount::INIT_SPACE,
        bump
    )]
    pub random_account_5: Box<Account<'info, RandomAccount>>,
}

#[account]
#[derive(InitSpace)]
pub struct RandomAccount {
    pub bump: u8,
}

This issue blocks early detection of potential stack overflow issues in our programs. Please investigate and restore the warning functionality to ensure developers are informed when the frame stack limit is exceeded.

@acheroncrypto
Copy link
Collaborator

For example, consider the following instruction context, which is guaranteed to cause an overflow in the frame stack.

It doesn't look like the example you gave should cause an overflow in v0.31 because the init constraint takes a lot less stack space than it did in previous versions (#2939).

There is a detailed explanation about this in the v0.31.0 release notes: https://www.anchor-lang.com/docs/updates/release-notes/0-31-0#stack-memory-improvements

@IaroslavMazur
Copy link
Author

It doesn't look like the example you gave should cause an overflow in v0.31 because the init constraint takes a lot less stack space than it did in previous versions

Hm... I admit there might've been a misconfiguration of the solana-cli/anchor configuration (as a result of working around the #3585 issue).

What I did experience was rolling back Anchor from v0.31 to v0.30, deploying it via v0.30 - and, then, facing some stack-frame-overflow-related issues on Devnet. Either v0.30 doesn't emit the warning when it should - or I've just overlooked it 🤷‍♂.


On another note, it's very impressive how many more accounts we can, now, initialize in an Ix Context in v0.31! And - even more suprprisingly - init_if_needed no longer takes up more space than the simpler init!

@acheroncrypto, congrats on this! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants