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

rustc SIGSEGV compiling rug 1.24.1 crate on RISC-V Armbian 24.5.0 #127180

Open
mathsDOTearth opened this issue Jun 30, 2024 · 4 comments
Open

rustc SIGSEGV compiling rug 1.24.1 crate on RISC-V Armbian 24.5.0 #127180

mathsDOTearth opened this issue Jun 30, 2024 · 4 comments
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-riscv Target: RISC-V architecture

Comments

@mathsDOTearth
Copy link

Code

[package]
name = "precisionTest"
version = "0.1.0"
edition = "2021"

[dependencies]
rug = "1.24.1"

use rug::{Assign, Float};

fn main() {
    // rust does not support 128-bit or larger floating point numbers natively
    // so we use the rug crate to simulate 128-bit and 256-bit floating point numbers
    // Define the precision for rug floating point vars
    let precision_128 = 128;
    let precision_256 = 256;

    let initial_value = 2.0 / 3.0;
    // Initialize floating point numbers
    
    let mut s23: f32 = initial_value; // Single precision (32-bit)
    let mut d23: f64 = initial_value as f64; // Double precision (64-bit)
    let mut q23 = Float::with_val(precision_128, initial_value);
    let mut e23 = Float::with_val(precision_256, initial_value);

    // Perform the first series of operations
    println!("Performing operations with initial values of 2/3");
    println!("{:<15} {:<20} {:<42} {:<20}", "s23 (f32)", "d23 (f64)", "q23 (rug float 128)", "e23 (rug float 256)");
    println!("{:<15} {:<20} {:<42} {:<20}", "---------", "---------", "---------", "---------");
    for _ in 1..=18 {
        s23 = s23 / 10.0 + 1.0;
        d23 = d23 / 10.0 + 1.0;
        q23 = q23 / 10.0 + 1.0;
        e23 = e23 / 10.0 + 1.0;
        println!("{:<15} {:<20} {:<42} {:<20}", s23, d23, q23, e23);
    }

    for _ in 1..=17 {
        s23 = (s23 - 1.0) * 10.0;
        d23 = (d23 - 1.0) * 10.0;
        q23 = (q23 - 1.0) * 10.0;
        e23 = (e23 - 1.0) * 10.0;
        println!("{:<15} {:<20} {:<42} {:<20}", s23, d23, q23, e23);
    }
}

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (ba1d7f4a0 2024-06-29)
binary: rustc
commit-hash: ba1d7f4a083e6402679105115ded645512a7aea8
commit-date: 2024-06-29
host: riscv64gc-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Error output

rich@bananapif3:~/rust/precisionTest$ cargo run
    Updating crates.io index
     Locking 16 packages to latest compatible versions
   Compiling gmp-mpfr-sys v1.6.4
   Compiling libc v0.2.155
   Compiling az v1.2.1
   Compiling libm v0.2.8
   Compiling rug v1.24.1
error: rustc interrupted by SIGSEGV, printing backtrace

/home/rich/.rustup/toolchains/nightly-riscv64gc-unknown-linux-gnu/bin/../lib/librustc_driver-b89e8be1f02fc7e1.so(+0xc5ce7c)[0x3f918eee7c]
linux-vdso.so.1(__vdso_rt_sigreturn+0x0)[0x3f9989c800]
/lib/riscv64-linux-gnu/libc.so.6(syscall+0x1c)[0x3f90aaae80]
/home/rich/.rustup/toolchains/nightly-riscv64gc-unknown-linux-gnu/bin/../lib/libstd-c9884c552aa40c8c.so(_ZN3std3sys4sync5mutex5futex5Mutex14lock_contended17ha8e3960d4d6da7beE+0x98)[0x3f90bbb342]
/home/rich/.rustup/toolchains/nightly-riscv64gc-unknown-linux-gnu/bin/../lib/libstd-c9884c552aa40c8c.so(_ZN3std3sys4sync7condvar5futex7Condvar4wait17h70cf2c3a001d1809E+0xaa)[0x3f90bfe9f6]
/home/rich/.rustup/toolchains/nightly-riscv64gc-unknown-linux-gnu/bin/../lib/librustc_driver-b89e8be1f02fc7e1.so(+0x5cf4dee)[0x3f96986dee]
/home/rich/.rustup/toolchains/nightly-riscv64gc-unknown-linux-gnu/bin/../lib/librustc_driver-b89e8be1f02fc7e1.so(+0x5cf5ba8)[0x3f96987ba8]
/home/rich/.rustup/toolchains/nightly-riscv64gc-unknown-linux-gnu/bin/../lib/librustc_driver-b89e8be1f02fc7e1.so(+0x5cf5bf8)[0x3f96987bf8]
/home/rich/.rustup/toolchains/nightly-riscv64gc-unknown-linux-gnu/bin/../lib/librustc_driver-b89e8be1f02fc7e1.so(+0x5cf62ba)[0x3f969882ba]
/home/rich/.rustup/toolchains/nightly-riscv64gc-unknown-linux-gnu/bin/../lib/librustc_driver-b89e8be1f02fc7e1.so(+0x5cf6c14)[0x3f96988c14]
/home/rich/.rustup/toolchains/nightly-riscv64gc-unknown-linux-gnu/bin/../lib/libstd-c9884c552aa40c8c.so(rust_metadata_std_7312307a1d21ac33+0x8623a)[0x3f90bfb23a]
/lib/riscv64-linux-gnu/libc.so.6(+0x710f4)[0x3f90a5a0f4]
/lib/riscv64-linux-gnu/libc.so.6(+0xc3908)[0x3f90aac908]

Backtrace

<backtrace>

@mathsDOTearth mathsDOTearth added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 30, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 30, 2024
@saethlin
Copy link
Member

saethlin commented Jul 1, 2024

I think you are running into the kernel bug linked from here: #117022 (comment)

@saethlin saethlin added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-riscv Target: RISC-V architecture and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 1, 2024
@bjorn3
Copy link
Member

bjorn3 commented Jul 1, 2024

Can we detect the kernel version in libstd's initialization code when on riscv and print a warning if the kernel is too old? That would save us from getting bugs reported every once in a while.

@rjzak
Copy link

rjzak commented Aug 3, 2024

I'm also having this issue on the new Deep Computing Roma II laptop, and I can't upgrade the kernel due presumably due to needed drivers not being upstreamed.

@bjorn3
Copy link
Member

bjorn3 commented Aug 3, 2024

Are you able to backport the fix and apply it to the vendor's version of the kernel and build hour own kernel? If so that would be a temporary solution until the necessary drivers are upstreamed.

@saethlin saethlin removed the C-bug Category: This is a bug. label Aug 3, 2024
@saethlin saethlin added C-discussion Category: Discussion or questions that doesn't represent real issues. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. O-riscv Target: RISC-V architecture
Projects
None yet
Development

No branches or pull requests

5 participants