Closed valentinegb closed 10 months ago
The problem is this
let mut grid: [[u32; 1000]; 1000] = [[0; 1000]; 1000];
This attempts to create a 4 MB allocation on the stack, which is pushing your luck when the default stack size is 8 MB. You get a segfault because we don't have stack protectors on aarch64.
This should work:
let mut grid: Vec<[u32; 1000]> = vec![[0; 1000]; 1000];
Yep, that was it. Thank you! There really ought to be a better error for this though...
There will be, when we get support for stack probes on aarch64: https://github.com/rust-lang/rust/issues/77071
I'm very sorry for how little information this bug report has, hopefully just, initially. I'm really not sure what exactly is going wrong here.
I have an Advent of Code project (the whole thing is here) where all the years and days are organized into their own files. This is the code I have in the file
dy6.rs
(day 6):The function
pt1()
(part 1) works as expected, butpt2()
crashes with a segmentation fault! I tried figuring out where exactly it's failing, and it seems like it's crashing just beforept2()
is called.This happens for me on both stable and nightly.
Meta
rustc --version --verbose
:No backtrace available.