Skip to content

debug build on M1 CPU: large arrays on stack fail with fatal runtime error: stack overflow #89908

Closed as not planned
@smoothdeveloper

Description

@smoothdeveloper

I tried this code:

    #[test]
    pub fn notpass() {
        let t = [0f32;526398];
        for i in 1 .. 20 {
            println!("{}", t[i]);
        }
    }

It crashes with

thread 'checkptrcast::tests::notpass' has overflowed its stack
fatal runtime error: stack overflow

when testing without the --release flag.

I'm running on Mac M1 and not tried yet on x64 architecture.

I'm looking to allocate much larger multidimensional array in the actual code and not sure how to proceed to make it work in debug builds.

Not sure if this is related: #40862 and if something could be done to help users troubleshooting this if the limitation in the compiler can't be fixed; maybe it could warn that the stack size is going to blow on the target arch?

warning: a stack allocated array of size X is defined here but it may panic at runtime on the Y target architecture.

or maybe not even compile and provide the user with approaches to replace usage of stack allocated array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions