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

LLVM ERROR: Too many bits for int64_t #112770

Open
matthiaskrgr opened this issue Jun 18, 2023 · 6 comments
Open

LLVM ERROR: Too many bits for int64_t #112770

matthiaskrgr opened this issue Jun 18, 2023 · 6 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-debug-assertions This issue requires debug-assertions in some way T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

#![feature(repr128)]
#[derive(PartialEq, Debug)]
#[repr(i128)]
enum Test {
    A(Box<u64>) = 0,
    B(usize) = u64::MAX as i128 + 1,
}

fn main() {
    assert_ne!(Test::A(Box::new(2)), Test::B(0));
    // This previously caused a segfault.
    //
    // See https://github.com/rust-lang/rust/issues/70509#issuecomment-620654186
    // for a detailed explanation.
}

Meta

rustc --version --verbose:

0c2c243342ec2a2427f0624fac5ac59f0ee6fbcd

Error output

warning: the feature `repr128` is incomplete and may not be safe to use and/or cause compiler crashes
 --> 100612.rs:1:12
  |
1 | #![feature(repr128)]
  |            ^^^^^^^
  |
  = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information
  = note: `#[warn(incomplete_features)]` on by default
Backtrace

rustc: /home/matthias/vcs/github/rust_debug_assertions/src/llvm-project/llvm/include/llvm/ADT/APInt.h:1519: int64_t llvm::APInt::getSExtValue() const: Assertion `getSignificantBits() <= 64 && "Too many bits for int64_t"' failed.
[2]    32637 IOT instruction  RUST_BACKTRACE=full ~/.rustup/toolchains/local-debug-assertions/bin/rustc

@matthiaskrgr matthiaskrgr added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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. C-bug Category: This is a bug. requires-debug-assertions This issue requires debug-assertions in some way labels Jun 18, 2023
@compiler-errors
Copy link
Member

What platform are you running this on? I can't repro this with a custom-built LLVM with debug assertions enabled on x86_64-unknown-linux-gnu.

@lukas-code
Copy link
Contributor

You need -Cdebuginfo=2 to reproduce.

This is the same as #100612, except it's now failing the assertion in LLVM instead of rustc.

@matthiaskrgr
Copy link
Member Author

#![feature(repr128)]

#[repr(u128)]
pub enum NotTrunctable {
    A = 0,
    B([u8; 1024]) = 1,
    C([u8; 4096]) = 0x10000000000000001,
}

pub fn trunc() {
  let mut a = NotTrunctable::A;
  a = NotTrunctable::B([0; 1024]);
}

pub fn main() {
  trunc();
}
warning: the feature `repr128` is incomplete and may not be safe to use and/or cause compiler crashes
 --> 52F3D9FC05D68B335092D7DEFC92AEAF218938602BBDEF4528FC527AB879E042.rs:1:12
  |
1 | #![feature(repr128)]
  |            ^^^^^^^
  |
  = note: see issue #56071 <https://github.com/rust-lang/rust/issues/56071> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: variable `a` is assigned to, but never used
  --> 52F3D9FC05D68B335092D7DEFC92AEAF218938602BBDEF4528FC527AB879E042.rs:11:11
   |
11 |   let mut a = NotTrunctable::A;
   |           ^
   |
   = note: consider using `_a` instead
   = note: `#[warn(unused_variables)]` on by default

warning: value assigned to `a` is never read
  --> 52F3D9FC05D68B335092D7DEFC92AEAF218938602BBDEF4528FC527AB879E042.rs:12:3
   |
12 |   a = NotTrunctable::B([0; 1024]);
   |   ^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` on by default

rustc: /home/matthias/vcs/github/rust_debug_assertions/src/llvm-project/llvm/include/llvm/ADT/APInt.h:1497: uint64_t llvm::APInt::getZExtValue() const: Assertion `getActiveBits() <= 64 && "Too many bits for uint64_t"' failed.
[1]    1502395 IOT instruction  ~/.rustup/toolchains/local-debug-assertions/bin/rustc  -Cdebuginfo=2

@istankovic
Copy link
Contributor

Cannot reproduce this with 1.75.0-nightly.

@matthiaskrgr
Copy link
Member Author

nightly doesn't have debug assertions, see the corresponding label

@istankovic
Copy link
Contributor

nightly doesn't have debug assertions, see the corresponding label

Eh, I thought -Cdebuginfo=2 would suffice... oh well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-debug-assertions This issue requires debug-assertions in some way T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants