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

Debuginfo changes causing ICE #55606

Closed
sophiajt opened this issue Nov 2, 2018 · 4 comments · Fixed by #55701
Closed

Debuginfo changes causing ICE #55606

sophiajt opened this issue Nov 2, 2018 · 4 comments · Fixed by #55701
Assignees

Comments

@sophiajt
Copy link
Contributor

sophiajt commented Nov 2, 2018

A recent change to debug info (possibly 0db7abe) seems to be causing ICEs with code like the following:

#![feature(never_type)]
#![feature(nll)]

#[derive(Copy, Clone)]
pub struct Entity {
    private: std::num::NonZeroU32,
}

#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Declaration;

impl TypeFamily for Declaration {
    type Base = Base;
    type Placeholder = !;

    fn intern_base_data(_: BaseKind<Self>) {}
}

#[derive(Copy, Clone)]
pub struct Base;

pub trait TypeFamily: Copy + 'static {
    type Base: Copy;
    type Placeholder: Copy;

    fn intern_base_data(_: BaseKind<Self>);
}

#[derive(Copy, Clone)]
pub enum BaseKind<F: TypeFamily> {
    Named(Entity),
    Placeholder(F::Placeholder),
    Error,
}

Compiled with:

rustc src/lib.rs -C debuginfo=2  --crate-type lib 

Edit: Platform info:

jonathan@pop-os:~/Source/lark/components/lark-ty$ rustc --version
rustc 1.31.0-nightly (de9666f12 2018-10-31)
@nikomatsakis
Copy link
Contributor

cc @tromey -- we believe this was caused by #54004 (bisection)

@nikomatsakis
Copy link
Contributor

Also, note that the exact rustc line is required (in particular, --crate-type lib).

The assertion failures I see are:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `18446744073709551615`,
 right: `340282366920938463463374607431768211455`', librustc_codegen_llvm/debuginfo/metadata.rs:1367:29
note: Run with `RUST_BACKTRACE=1` for a backtrace.

with this backtrace found here.

@tromey tromey self-assigned this Nov 2, 2018
@tromey
Copy link
Contributor

tromey commented Nov 2, 2018

You can make it fail without --crate-type lib by adding a main that uses BaseKind:

pub fn main() {
    let x = BaseKind::Error::<Declaration>;
    let y = 7;
}

@tromey
Copy link
Contributor

tromey commented Nov 2, 2018

This assert:

assert_eq!(niche as u64 as u128, niche);

is wrong if niche underflows to -1u128.

Just removing the assert is probably fine. However I wonder if the values should actually be truncated to the size of the tag slot.

tromey added a commit to tromey/rust that referenced this issue Nov 5, 2018
Bug rust-lang#55606 points out a regression introduced by rust-lang#54004; namely that
an assertion can erroneously fire when a niche-filling discriminant
value is emitted.

This fixes the bug by removing the assertion, and furthermore by
arranging for the discriminant value to be masked according to the
size of the niche.  This makes handling the discriminant a bit simpler
for debuggers.

The test case is from Jonathan Turner.

Closes rust-lang#55606
bors added a commit that referenced this issue Nov 12, 2018
Fix emission of niche-filling discriminant values

Bug #55606 points out a regression introduced by #54004; namely that
an assertion can erroneously fire when a niche-filling discriminant
value is emitted.

This fixes the bug by removing the assertion, and furthermore by
arranging for the discriminant value to be masked according to the
size of the niche.  This makes handling the discriminant a bit simpler
for debuggers.

The test case is from Jonathan Turner.

Closes #55606
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants