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

ICE: librustc_trans/mir/constant.rs:682: Unexpected non-fat-pointer operand #38942

Closed
fenollp opened this issue Jan 9, 2017 · 19 comments
Closed
Assignees
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fenollp
Copy link

fenollp commented Jan 9, 2017

Here is the Travis job that fails: https://travis-ci.org/fenollp/minrs/jobs/190200414
Which is part of this build https://travis-ci.org/fenollp/minrs/builds/190200409

$ rustc --version
rustc 1.14.0 (e8a012324 2016-12-16)
$ cargo --version
cargo 0.15.0-nightly (298a012 2016-12-20)

This only happens on i686-apple-darwin & on Travis' OSX hardware.

Possibly linked: #38727 #16383 #37437 #38735

@nagisa
Copy link
Member

nagisa commented Jan 9, 2017

Inline assembly cannot be an issue as this is an ICE on stable rustc. #38727 is fixed on nightly, so you’ll have to test/do travis run on i686 apple with nightly rustc.

fenollp added a commit to voidstarHQ/minrs that referenced this issue Jan 9, 2017
@fenollp
Copy link
Author

fenollp commented Jan 9, 2017

Here's a Travis run on nightly rustc with i686 apple platform: https://travis-ci.org/fenollp/minrs/jobs/190236515#L233

That bug looks fixed. However now I have

error: internal compiler error: /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc_trans/mir/constant.rs:682: Unexpected non-fat-pointer operand

which Google doesn't seem to know about!

fenollp added a commit to voidstarHQ/minrs that referenced this issue Jan 9, 2017
@nagisa
Copy link
Member

nagisa commented Jan 10, 2017

cc @eddyb @Mark-Simulacrum stuff related to type_is_immediate change could have caused this.

fenollp added a commit to voidstarHQ/minrs that referenced this issue Jan 10, 2017
* ci: thx github.com/japaric/trust

* ci: bump trust to v0.1.1

* ci: DISABLE_TESTS=1

* ci: DISABLE_TESTS=1 on AppVeyor too

* ci: allow_failures

* ci: fix OSX builds

* ci: honor script.sh logic for AppVeyor too

* ci: try i686 apple with nightly rustc for rust-lang/rust/issues/38942

* ci: really fix OSX builds

* ci: really really fix OSX builds

* ci: fix allow_failures

* ci: run something if you really want to

* ci: do not disable tests

* ci: Cargo.lock

* ci: exec basic help for starters

* ci: late night fix
@eddyb
Copy link
Member

eddyb commented Jan 10, 2017

#38854 hasn't landed so it's not that. @dotdash may have also ran into this but I'm not sure.

@brson brson added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 11, 2017
@fenollp fenollp changed the title ICE: librustc_trans/mir/operand.rs:82: impossible case reached ICE: librustc_trans/mir/constant.rs:682: Unexpected non-fat-pointer operand Jan 12, 2017
@brson brson added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. P-high High priority labels Jan 12, 2017
@nikomatsakis
Copy link
Contributor

So all it takes to reproduce is building https://github.com/fenollp/minrs on an i686-mac?

@nikomatsakis
Copy link
Contributor

Or must it specifically be run on travis? If so, we should try to isolate what is different there!

@nikomatsakis
Copy link
Contributor

Assigning to @pnkfelix for now, who will attempt to reproduce with a cross-compile.

@pnkfelix
Copy link
Member

pnkfelix commented Jan 13, 2017

Summary: I have now managed to reproduce. Steps follow.

Initial comment: Hmm, well I think I have the cross-compile set up now (I wrote the steps I followed below), but I think I am hitting the first ICE described ("internal compiler error: ../src/librustc_trans/mir/operand.rs:82: impossible case reached"), so I have not yet replicated the "Unexpected non-fat-pointer operand").

Steps to set up cross compile

  1. On a Mac, you need to make sure you have the ability to cross-compile to i686-apple-darwin. I used https://rustup.rs/ with a default of the nightly channel as an easy way to get that set up.
% rustup default nightly
% rustup target add i686-apple-darwin
%
  1. With cross compiling support established, we do a build to demonstrate the ICE:
% cargo build -j1 --target i686-apple-darwin 
   [...]
   Compiling cocoa v0.5.2
error: internal compiler error: /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc_trans/mir/operand.rs:82: impossible case reached

Update: but then again, with the stable channel I am hitting the same ICE ...? Maybe I still have something wrong here.

Update to update: I think I misread some of the initial discussion; the original description was filed against stable, so I cannot actually compare against a stable version because it is guaranteed to hit the described ICE. I'm going to see if changing my particular nightly changes anything here.


Okay, backtracking to the specific nightly of rustc from the time that this bug was filed has allowed me to replicate. (Also, doing a build for the host's x86_64-apple-darwin target did compile to the end successfully.)

So, how to do that:

% rustup default nightly-2017-01-08
% rustup target add i686-apple-darwin
% cargo build --target i686-apple-darwin
   [...]
   Compiling cocoa v0.3.3
error: internal compiler error: /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc_trans/mir/constant.rs:682: Unexpected non-fat-pointer operand

@eddyb
Copy link
Member

eddyb commented Jan 13, 2017

Can you use RUST_LOG=rustc_trans::base to reduce it to at least one function? (This works on release compilers too, I think, since it's info!)

@pnkfelix
Copy link
Member

Talked to @eddyb on IRC. The last line of output from the rust log for rustc_trans::base is:

INFO:rustc_trans::base: trans_instance(<appkit::NSEventMask as std::fmt::Debug>::fmt::dummy::fmt)

@fenollp
Copy link
Author

fenollp commented Jan 13, 2017

I noticed this before, might be of interest:

   Compiling cocoa v0.3.3

appears when the constant.rs bug gets triggered, however the operand.rs one has cocoa v0.5.2.

@eddyb
Copy link
Member

eddyb commented Jan 13, 2017

@fenollp Ah that would definitely be able to trigger 2 distinct bugs.

@pnkfelix
Copy link
Member

pnkfelix commented Jan 13, 2017

Okay here is a minimized example for the unexpected fat pointer operand ICE. It only comes up with i686 (-apple-darwin), though hopefully that is not relevant), not with x86_64

Code:

// This causeds an ICE when targeting i686-apple-darwin (from a
// x86_64-apple-darwin host).

#![crate_name = "cocoa"]
#![crate_type = "rlib"]

#![allow(non_upper_case_globals)]

pub mod appkit {
    use std::fmt::{self};

    #[repr(u64)]
    pub enum NSEventType {
        NSEventTypePressure = 34,
    }

    pub struct NSEventMask {
        bits: u64,
    }

    pub const NSEventMaskPressure: NSEventMask =
        NSEventMask{bits: 1 << (NSEventType::NSEventTypePressure as u64),};

    impl fmt::Debug for NSEventMask {
        fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            if NSEventMaskPressure.bits != 0 {
                match f.write_str("NSEventMaskPressure") {
                    Ok(val) => val,
                    Err(err) => {
                        return Err(From::from(err))
                    }
                }
            }
            Ok(())
        }
    }
}

And here's the run:

% rustc --version
rustc 1.16.0-nightly (47c8d9fdc 2017-01-08)
% rustc /tmp/issue-38942.rs --target x86_64-apple-darwin
% rustc /tmp/issue-38942.rs --target i686-apple-darwin
error: internal compiler error: /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc_trans/mir/constant.rs:682: Unexpected non-fat-pointer operand

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

thread 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc_errors/lib.rs:423
note: Run with `RUST_BACKTRACE=1` for a backtrace.

% 

@pnkfelix
Copy link
Member

pnkfelix commented Jan 13, 2017

Also reproduced minimized example still ICE's with a more recent nightly:

rustc 1.16.0-nightly (1a2ed98d3 2017-01-13)

@eddyb
Copy link
Member

eddyb commented Jan 13, 2017

Oh this is a non-immediate CEnum, I bet #38854 fixes it, and I can't think of a nicer solution.

@pnkfelix pnkfelix added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 13, 2017
@nagisa
Copy link
Member

nagisa commented Jan 13, 2017

The more-minimal version. Thanks for minimizing @pnkfelix!

#![crate_type = "rlib"]

#[repr(u64)]
pub enum NSEventType {
    NSEventTypePressure,
}

pub const A: u64 = NSEventType::NSEventTypePressure as u64;

fn banana() -> u64 {
    A
}

@pnkfelix
Copy link
Member

pnkfelix commented Jan 13, 2017

(if #38854 does fix it, we probably should try to add this as a regression test if possible before closing, assuming we can readily do cross target unit test.)

@eddyb
Copy link
Member

eddyb commented Jan 13, 2017

Do you even need the shift? I bet it's just the cast. The test doesn't need to be special as long as we build for 32-bit targets, it will get caught.

@nagisa
Copy link
Member

nagisa commented Jan 14, 2017

Tried compiling the test case with compiler built from commit d70cd49 (inlcudes the #38854), but it still ICEs.

EDIT: never mind, it works. build system is weird.

michaelwoerister added a commit to michaelwoerister/rust that referenced this issue Jan 19, 2017
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 20, 2017
…crichton

Add regression test for issue rust-lang#38942

Closes rust-lang#38942.

Kudos to @pnkfelix and @nagisa, who did all the hard work of creating a reduced test case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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

6 participants