Skip to content
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 overflow error when interacting with testnet contract #1588

Open
leighmcculloch opened this issue Sep 10, 2024 · 3 comments · May be fixed by #1593
Open

Stack overflow error when interacting with testnet contract #1588

leighmcculloch opened this issue Sep 10, 2024 · 3 comments · May be fixed by #1593
Labels
bug Something isn't working

Comments

@leighmcculloch
Copy link
Member

leighmcculloch commented Sep 10, 2024

What version are you using?

v21.4.1

What did you do?

$ stellar contract invoke --id CASQBSZXLPBXKAS7B556ARFKZI4UNVJKGM4SBZMRUS4OCXVDILOUVHMC --network testnet -- -h

What did you expect to see?

Help output for the contract.

What did you see instead?

thread 'main' has overflowed its stack
fatal runtime error: stack overflow

Reported by @kalepail in Discord:

@leighmcculloch leighmcculloch added the bug Something isn't working label Sep 10, 2024
@leighmcculloch
Copy link
Member Author

Inspecting the contract, it appears to have a recursive contracttype definition. I don't know if that is the cause, but recursive data structure and stack overflow could go hand in hand.

$ stellar contract fetch --id CASQBSZXLPBXKAS7B556ARFKZI4UNVJKGM4SBZMRUS4OCXVDILOUVHMC --network testnet -o contract.wasm
$ stellar contract bindings rust --wasm contract.wasm
pub const WASM: &[u8] = soroban_sdk::contractfile!(
    file = "CASQBSZXLPBXKAS7B556ARFKZI4UNVJKGM4SBZMRUS4OCXVDILOUVHMC.wasm", sha256 =
    "4858768f584c661d9a839bf84d75f12bcf1705ef031fdbec5becd0ab367af0f6"
);
#[soroban_sdk::contractclient(name = "Client")]
pub trait Contract {
    fn init(
        env: soroban_sdk::Env,
        wasm_hash: soroban_sdk::BytesN<32>,
    ) -> Result<(), soroban_sdk::Error>;
    fn deploy(
        env: soroban_sdk::Env,
        salt: soroban_sdk::BytesN<32>,
        id: Signer,
    ) -> Result<soroban_sdk::Address, soroban_sdk::Error>;
}
#[soroban_sdk::contracttype(export = false)]
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Policy(pub soroban_sdk::Address);
#[soroban_sdk::contracttype(export = false)]
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Ed25519PublicKey(pub soroban_sdk::BytesN<32>);
#[soroban_sdk::contracttype(export = false)]
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Secp256r1Id(pub soroban_sdk::Bytes);
#[soroban_sdk::contracttype(export = false)]
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub enum Signer {
    Policy(Policy, soroban_sdk::Vec<Signer>),
    Ed25519(Ed25519PublicKey),
    Secp256r1(Secp256r1Id, soroban_sdk::BytesN<65>),
}
#[soroban_sdk::contracterror(export = false)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub enum Error {
    NotInitialized = 1,
    AlreadyInitialized = 2,
}

Specifically the Signer type:

pub enum Signer {
    Policy(Policy, soroban_sdk::Vec<Signer>),

@kalepail
Copy link
Contributor

Removing this recursion definitely cleared up this issue fwiw

@willemneal
Copy link
Member

Looking into it here: #1593

@willemneal willemneal linked a pull request Sep 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog (Not Ready)
Development

Successfully merging a pull request may close this issue.

3 participants