Skip to content

possible miscompilation on aarch64 #117077

@sarah-quinones

Description

@sarah-quinones

this code runs to completion when executed with miri or on x86, but segfaults on aarch64 in release builds

[package]
name = "faer-aarch64-bug"
version = "0.1.0"
edition = "2021"

[dependencies]
dyn-stack = "0.10.0"
faer-core = "0.14.1"
faer-svd = "0.14.1"
pulp = "0.17.1"
gemm = "0.16.14"
rand = "0.8.5"

[profile.release]
codegen-units=1
use dyn_stack::PodStack;
use faer_core::Mat;
use faer_svd::compute_svd;
use rand::{Rng, SeedableRng};

fn main() {
    let nrows = 5;
    let ncols = 5;
    let size = Ord::min(nrows, ncols);

    let mut gen = rand::rngs::StdRng::seed_from_u64(0);
    for _ in 0..10 {
        let m = Mat::from_fn(nrows, ncols, |_, _| {
            gen.gen::<f64>()
        });
        let mut s = Mat::<f64>::zeros(size, 1);
        let mut u = Mat::<f64>::zeros(nrows, nrows);
        let mut v = Mat::<f64>::zeros(ncols, ncols);

        compute_svd(
            m.as_ref(),
            s.as_mut(),
            Some(u.as_mut()),
            Some(v.as_mut()),
            faer_core::Parallelism::None,
            PodStack::new(&mut vec![0u8; 1024 * 1024]),
            Default::default(),
        );
    }
}

i tried isolating the issue but it's very elusive, and randomly disappears as different functions get inlined or noinlined, so the best i have is this example here

Meta

rustc --version --verbose:

rustc 1.75.0-nightly (1c05d50c8 2023-10-21)
binary: rustc
commit-hash: 1c05d50c8403c56d9a8b6fb871f15aaa26fb5d07
commit-date: 2023-10-21
host: aarch64-apple-darwin
release: 1.75.0-nightly
LLVM version: 17.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkersArea: linkers... you gotta love linkersC-external-bugCategory: issue that is caused by bugs in software beyond our controlI-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessO-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