-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
debug build on M1 CPU: large arrays on stack fail with fatal runtime error: stack overflow #89908
Comments
Context: I was trying to convert C++ code which deals with a pointer to a class instance member being such large array, although in that code, the array isn't allocated on the stack (class is "newed"). I've been pointed at bytemuck and cast_vec for working around the issue I'm dealing with in the code. Is it worth it/possible for the compiler to emit a warning? |
@smoothdeveloper You are explicitly creating the array on the stack. The testing framework creates threads for multi-threaded testing and the default stack size for threads created from within Rust is 2 MiB. So this will predictably fail on all architectures. @rustbot label -O-ARM -O-macos |
Triage: Thanks for reporting. No matter what stack size is default, it will always be too small for someone. In this case it should work to make it bigger with RUST_MIN_SIZE. Let's close this. |
I tried this code:
It crashes with
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?
or maybe not even compile and provide the user with approaches to replace usage of stack allocated array.
The text was updated successfully, but these errors were encountered: