coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.66k stars 1.34k forks source link

failed: Access violation in stack frame 5 at address 0x200005ee0 of size 8 #3332

Closed cxp-13 closed 5 days ago

cxp-13 commented 5 days ago

Version:

cxp@R9000P:~/solana_learn/xenobunny/xenobunny-new/xenobunny-rust$ rustc -V
rustc 1.75.0 (82e1608df 2023-12-21)
cxp@R9000P:~/solana_learn/xenobunny/xenobunny-new/xenobunny-rust$ solana -V
solana-cli 1.17.22 (src:dbf06e25; feat:3580551090, client:SolanaLabs)
cxp@R9000P:~/solana_learn/xenobunny/xenobunny-new/xenobunny-rust$ anchor -V
anchor-cli 0.30.1

Code:

#[derive(Accounts)]
#[instruction(collection_nft_mint: Pubkey)]
pub struct MintNft<'info> {
    #[account(
        init,
        seeds = [nft_mint.key().as_ref(), WARRITOR_CARD_STATE.as_bytes()],
        bump,
        payer = user,
        space = 8 + std::mem::size_of::<WarriorCardState>()
    )]
    pub warrior_card_state: Box<Account<'info, WarriorCardState>>,
    #[account(
        init,
        seeds = [
            user.key().as_ref(),
            collection_nft_mint.as_ref(),
            WARRITOR_CARDS_USAGE_TRACKER.as_bytes(),
        ],
        bump,
        payer = user,
        space = 8 + std::mem::size_of::<WarriorCardsUsageTracker>()
    )]
    pub warrior_cards_usage_tracker: Box<Account<'info, WarriorCardsUsageTracker>>,
    #[account(seeds = [MINT_NFT_CONFIG.as_bytes()], bump)]
    pub nft_mint_config: Box<Account<'info, NFTMintConfig>>,
    #[account(
        init,
        payer = user,
        mint::decimals = 0,
        mint::authority = mint_authority,
        mint::freeze_authority = mint_authority
    )]
    pub nft_mint: Box<Account<'info, Mint>>,
    // #[account(
    //     mint::decimals = 0,
    //     mint::authority = mint_authority,
    //     mint::freeze_authority = mint_authority,
    //     seeds = [XENOBUNNY_NFT_COLLECTION.as_bytes()],
    //     bump
    // )]
    // pub collection_nft_mint: Account<'info, Mint>,
    #[account(
        init,
        payer = user,
        associated_token::mint = nft_mint,
        associated_token::authority = user
    )]
    pub user_ata: Box<Account<'info, TokenAccount>>,
    /// CHECK: This is a PDA account, safe to skip verification
    #[account(seeds = [MINT_AUTHORITY.as_bytes()], bump)]
    pub mint_authority: UncheckedAccount<'info>,
    /// CHECK: Created by the metadata program and does not require checking
    #[account(mut)]
    pub metadata_account: UncheckedAccount<'info>,
    #[account(mut)]
    pub user: Signer<'info>,
    pub token_program: Program<'info, Token>,
    /// CHECK: This is a PDA account, safe to skip verification
    #[account(address = TOKEN_METADATA_ID)]
    pub token_metadata_program: UncheckedAccount<'info>,
    pub system_program: Program<'info, System>,
    pub associated_token_program: Program<'info, AssociatedToken>,
}

I referred the previous suggestion(https://github.com/coral-xyz/anchor/issues/3089) and Box some account, but it still show failed: Access violation in stack frame 5 at address 0x200005ee0 of size 8

when I try to using Solana CLI 1.17.22

[dependencies]
anchor-lang = { version = "0.30.1", features = ["init-if-needed"] }
anchor-spl = "0.30.1"
spl-token-2022 = "3.0.4"
solana-program = "1.18.20"
mpl-token-metadata = "4.1.2"

That is my actions

cxp@R9000P:~/solana_learn/xenobunny/xenobunny-new/xenobunny-rust$ solana-install init 1.17.22
  ✨ 1.17.22 initialized
cxp@R9000P:~/solana_learn/xenobunny/xenobunny-new/xenobunny-rust$ anchor build
info: uninstalling toolchain 'solana'
info: toolchain 'solana' uninstalled
error: package `num_enum_derive v0.7.3` cannot be built because it requires rustc 1.70.0 or newer, while the currently active rustc version is 1.68.0-dev
Either upgrade to rustc 1.70.0 or newer, or use
cargo update -p num_enum_derive@0.7.3 --precise ver
where `ver` is the latest version of `num_enum_derive` supporting rustc 1.68.0-dev
acheroncrypto commented 5 days ago

This will be fixed in the next version (https://github.com/coral-xyz/anchor/pull/3259). See Stack memory improvements if you want to learn more.

cxp-13 commented 5 days ago

This will be fixed in the next version (#3259). See Stack memory improvements if you want to learn more. I optimized the program and successfully compiled it.