Skip to content

Rust app crashes with segmentation fault #117334

Closed
@kuzemchik

Description

@kuzemchik

Code compiled with Rust 1.70.0, 1.72.1, 1.73.0 yields code that is failing with segmentation fault in runtime.

I tried this code:

use std::convert::TryInto;
fn main() {
	let data:[f32; 1000*1000] = vec![1.0; 1000*1000]
        .try_into()
        .expect("Wrong matrix size!");
    print!("Result {}\n",data[0])	
}

I expected to see this happen:

  • "Result 1"
  • "Wrong matrix size!"
  • Compilation Error
  • Stack overflow

Instead, this happened:

  • segmentation fault (signal: 11, SIGSEGV: invalid memory reference)

Code below works (just dropping the size of vec/array)

use std::convert::TryInto;
fn main() {
	let data:[f32; 100*100] = vec![1.0; 100*100]
        .try_into()
        .expect("Wrong matrix size!");
    print!("Result {}\n",data[0])	
}

Meta

rustc --version --verbose:

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: aarch64-apple-darwin
release: 1.70.0
LLVM version: 16.0.2
rustc 1.72.1 (d5c2e9c34 2023-09-13)
binary: rustc
commit-hash: d5c2e9c342b358556da91d61ed4133f6f50fc0c3
commit-date: 2023-09-13
host: aarch64-apple-darwin
release: 1.72.1
LLVM version: 16.0.5
rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: aarch64-apple-darwin
release: 1.73.0
LLVM version: 17.0.2
Backtrace

➜  bug_report RUST_BACKTRACE=1 cargo build
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
➜  bug_report RUST_BACKTRACE=1 cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/bug_report`
[1]    39304 segmentation fault  RUST_BACKTRACE=1 cargo run

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-stack-probeArea: Stack probing and guard pagesC-bugCategory: This is a bug.O-AArch64Armv8-A or later processors in AArch64 modeO-macosOperating system: macOST-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions