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

rust program that allocates a large temporary segfaults on MacOS #107814

Closed
squell opened this issue Feb 8, 2023 · 2 comments
Closed

rust program that allocates a large temporary segfaults on MacOS #107814

squell opened this issue Feb 8, 2023 · 2 comments
Labels
A-stack-probe Area: Stack probing and guard pages C-bug Category: This is a bug. O-AArch64 Armv8-A or later processors in AArch64 mode

Comments

@squell
Copy link
Contributor

squell commented Feb 8, 2023

While playing around with rustc 1.69.0-nightly (bd39bbb 2023-02-07) on MacOS, I ran into the following:

//const N: usize = 2_088_032; // largest size that works without abort
const N: usize = 2_092_349; // first segfault 

fn main () {
    let _ = Box::new([0; N]);
}

With N <= 2088032 this program works fine; above that the binary that rustc makes produces a runtime abort. Both are acceptable outcomes.

But with N >= 2092349 running the program results in a segmentation fault instead. It sounds like something has destroyed something that the stack unwinder relies on?

Meta

rustc --version --verbose:

rustc 1.69.0-nightly (bd39bbb4b 2023-02-07)
binary: rustc
commit-hash: bd39bbb4bb92df439bf6d85470e296cc6a47ffbd
commit-date: 2023-02-07
host: aarch64-apple-darwin
release: 1.69.0-nightly
LLVM version: 15.0.7
Backtrace

n/a (the compiled program segfaults)

@squell squell added the C-bug Category: This is a bug. label Feb 8, 2023
@workingjubilee workingjubilee added O-AArch64 Armv8-A or later processors in AArch64 mode A-stack-probe Area: Stack probing and guard pages labels Feb 9, 2023
@workingjubilee
Copy link
Member

I believe this is a consequence of not properly probing the stack due to the lack of support for it on aarch64.

@luqmana
Copy link
Member

luqmana commented Sep 19, 2024

Looks like this has since been resolved (#118491 enabled inline stack probes for aarch64).

$ rustc +1.68-aarch64-apple-darwin crash.rs
$ ./crash
[1]    57080 segmentation fault  ./crash

$  rustc +nightly -vV
rustc 1.83.0-nightly (f79a912d9 2024-09-18)
binary: rustc
commit-hash: f79a912d9edc3ad4db910c0e93672ed5c65133fa
commit-date: 2024-09-18
host: aarch64-apple-darwin
release: 1.83.0-nightly
LLVM version: 19.1.0

$ rustc +nightly crash.rs
$ ./crash

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
[1]    57097 abort      ./crash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-stack-probe Area: Stack probing and guard pages C-bug Category: This is a bug. O-AArch64 Armv8-A or later processors in AArch64 mode
Projects
None yet
Development

No branches or pull requests

4 participants