rust-lang / rust-lang/rust

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

Open
#127,180 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-discussion I-crash O-riscv
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the SIGSEGV with the supplied precisionTest package using cargo run on the reported riscv64 host, then compare stable, beta, and nightly rustc versions. Use the crash backtrace and the rug/gmp-mpfr-sys compilation steps to narrow the compiler failure; done means the reduced case no longer crashes or the responsible rustc component has a regression test and fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.