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 in libsyntax/diagnostic.rs #21756

Closed
swizard0 opened this issue Jan 29, 2015 · 11 comments
Closed

ICE in libsyntax/diagnostic.rs #21756

swizard0 opened this issue Jan 29, 2015 · 11 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@swizard0
Copy link

% uname -a 
Darwin pair 14.1.0 Darwin Kernel Version 14.1.0: Mon Dec 22 23:10:38 PST 2014; root:xnu-2782.10.72~2/RELEASE_X86_64 x86_64

% rustc --version --verbose
rustc 1.0.0-dev (a45e11773 2015-01-28 11:01:36 +0000)
binary: rustc
commit-hash: a45e117733b866302fa99390553d1c548508dcca
commit-date: 2015-01-28 11:01:36 +0000
host: x86_64-apple-darwin
release: 1.0.0-dev

% RUST_BACKTRACE=1 rustc --cfg=test rs_ffi_utils.rs
rs_ffi_utils.rs:236:1: 248:2 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `MemWrite` for the type `Seq<&'o T>`
rs_ffi_utils.rs:236 impl<'o, T> MemWrite for Seq<&'o T> where T: Blob, &'o T: MemWrite {
rs_ffi_utils.rs:237     fn write_to_mem<'a>(&self, dst: &'a mut [u8]) -> Result<&'a [u8], MemAreaError> {
rs_ffi_utils.rs:238         Ok(dst)
rs_ffi_utils.rs:239     }
rs_ffi_utils.rs:240
rs_ffi_utils.rs:241     fn size_required(&self) -> usize {
                    ...
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /Users/swizard/distr/rust/src/libsyntax/diagnostic.rs:130

stack backtrace:
   1:        0x10dda37a7 - sys::backtrace::write::ha7c2a314980a2c9fvbu
   2:        0x10ddc9c5c - failure::on_fail::h6e454f5b61899a9aqbB
   3:        0x10dd2b068 - rt::unwind::begin_unwind_inner::h197e2c88eee2bed0mTA
   4:        0x10d4b2897 - rt::unwind::begin_unwind::h2026034157403174692
   5:        0x10d4b282c - diagnostic::SpanHandler::span_bug::hd1799d165b9b1455PGE
   6:        0x10aff6d1a - middle::traits::error_reporting::report_fulfillment_errors::hea46febf461f61d7YHN
   7:        0x10a95ed38 - check::vtable::select_all_fcx_obligations_or_error::h76d8a7711ec3b289Upb
   8:        0x10a9da0ae - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>::check_item_well_formed::h1acd04dfde9bfc73a7i
   9:        0x10aac784e - check_crate::closure.32081
  10:        0x10aac2e0f - check_crate::haecc3fe6465ec7b6ZNy
  11:        0x10a48c8eb - driver::phase_3_run_analysis_passes::h79664d81b6b5b4e4NFa
  12:        0x10a472e5c - driver::compile_input::hec1fc484fb82a3b3Bba
  13:        0x10a53b50e - run_compiler::hc5f9e0285db79a55n9b
  14:        0x10a53862f - thunk::F.Invoke<A, R>::invoke::h4736678281155978274
  15:        0x10a5372c0 - rt::unwind::try::try_fn::h3346791736825056138
  16:        0x10de42a09 - rust_try_inner
  17:        0x10de429f6 - rust_try
  18:        0x10a537984 - thunk::F.Invoke<A, R>::invoke::h14937575134341006880
  19:        0x10ddb4313 - sys::thread::thread_start::hd065b218eff37dc2J3w
  20:     0x7fff87bec268 - _pthread_body
  21:     0x7fff87bec1e5 - _pthread_body
@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 29, 2015
@jdm
Copy link
Contributor

jdm commented Feb 4, 2015

#21942 reports that the nalgebra library hits this.

@ebfull
Copy link
Contributor

ebfull commented Feb 13, 2015

image library seems to hit this too:

/root/.cargo/git/checkouts/image-f4d4ca6613133df7/master/src/imageops/colorops.rs:62:46: 62:66 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `traits::Num` for the type `<<I as image::GenericImage>::Pixel as buffer::Pixel>::Subpixel`
/root/.cargo/git/checkouts/image-f4d4ca6613133df7/master/src/imageops/colorops.rs:62     let max: <I::Pixel as Pixel>::Subpixel = Primitive::max_value();
                                                                                                                                  ^~~~~~~~~~~~~~~~~~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /rustc-nightly/src/libsyntax/diagnostic.rs:129

stack backtrace:
   1:     0x7f53cd4f14b0 - sys::backtrace::write::h7f470cc4f24154a6ZTA
   2:     0x7f53cd516140 - failure::on_fail::h61642dd3c2c5b7f9JFJ
   3:     0x7f53cd46e0b0 - rt::unwind::begin_unwind_inner::hd970c8feb3e9463d4jJ
   4:     0x7f53ca812410 - rt::unwind::begin_unwind::h3673386443430583256
   5:     0x7f53ca8123a0 - diagnostic::SpanHandler::span_bug::h5ed17cc567e332df74E
   6:     0x7f53cb585c60 - middle::traits::error_reporting::report_fulfillment_errors::hc272c1e020beb1a9suO
   7:     0x7f53ccbb7ad0 - check::vtable::select_all_fcx_obligations_or_error::h34bbe66b3fb3edf0oPb
   8:     0x7f53ccc64410 - check::check_bare_fn::h727526b64e64c055Scn
   9:     0x7f53ccc5bb10 - check::check_item::h2ba91f101eebedf8lwn
  10:     0x7f53ccc62100 - visit::walk_item::h7118923990314441683
  11:     0x7f53ccc62100 - visit::walk_item::h7118923990314441683
  12:     0x7f53ccd2f480 - check_crate::closure.35395
  13:     0x7f53ccd29d50 - check_crate::hd29eb55a52d61a01OxB
  14:     0x7f53cdb1ec80 - driver::phase_3_run_analysis_passes::h6d35bf1217485c05SGa
  15:     0x7f53cdb04d60 - driver::compile_input::h782a70ecc086dc68Eba
  16:     0x7f53cdbd5f30 - run_compiler::had38ec949ad218b25bc
  17:     0x7f53cdbd4590 - thunk::F.Invoke<A, R>::invoke::h12150908996860458254
  18:     0x7f53cdbd3480 - rt::unwind::try::try_fn::h16942177747375777417
  19:     0x7f53cd58b980 - rust_try_inner
  20:     0x7f53cd58b970 - rust_try
  21:     0x7f53cdbd3730 - thunk::F.Invoke<A, R>::invoke::h6840892055334168534
  22:     0x7f53cd501db0 - sys::thread::thread_start::h4240f311c9074a7baOE
  23:     0x7f53c764ffe0 - start_thread
  24:     0x7f53cd0ecc99 - __clone
  25:                0x0 - <unknown>

i'm running on a more recent rust version as well:

rustc 1.0.0-dev (39b463f15 2015-02-12 20:03:50 +0000)
binary: rustc
commit-hash: 39b463f15328f448c13fa990f9fc8897e0af55c2
commit-date: 2015-02-12 20:03:50 +0000
host: x86_64-unknown-linux-gnu
release: 1.0.0-dev

@nwin
Copy link
Contributor

nwin commented Feb 14, 2015

This must have been introduced recently rustc 1.0.0-nightly (3ef8ff1 2015-02-12 00:38:24 +0000) works…

@tomaka
Copy link
Contributor

tomaka commented Feb 14, 2015

The issue has been reported 16 days ago, so it wasn't introduced recently. However image started hitting this with the 2015-02-13 nightly.

@AnthIste
Copy link

Trying to run this snippet in the rust playpen gives an ICE:

trait MyTrait {
    fn do_something(&self);
}

impl<'a> MyTrait for MyTrait + 'a {
    fn do_something(&self) {
        println!("MyTrait");
    }
}

fn main() {
}

The error log is:

<anon>:5:1: 9:2 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `MyTrait` for the type `MyTrait + 'a`
<anon>:5 impl<'a> MyTrait for MyTrait + 'a {
<anon>:6     fn do_something(&self) {
<anon>:7         println!("MyTrait");
<anon>:8     }
<anon>:9 }
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:129

@fenhl
Copy link
Contributor

fenhl commented Apr 2, 2015

router will hit this too, as soon as iron/router#74 is merged.

@andrew-d
Copy link
Contributor

andrew-d commented Apr 3, 2015

I took a quick look at this and it's beyond my knowledge to fix, but the bug is being triggered here, and it looks like maybe @nikomatsakis or @flaper87 was the last one to touch that code?

@nikomatsakis
Copy link
Contributor

Hmm so the minimized code snippet here:

trait MyTrait {
    fn do_something(&self);
}

impl<'a> MyTrait for MyTrait + 'a {
    fn do_something(&self) {
        println!("MyTrait");
    }
}

fn main() {
}

is actually just broken code. That is, the compiler automatically generates an impl of MyTrait for MyTrait, so you shouldn't need to write one -- but we should give a better error, of course.

@nikomatsakis
Copy link
Contributor

I have a fix for some of these problems which I'm going to post, but I suspect there are different issues arising, so I'm not going to declare this bug fixed until I've been able to investigate more of the crates in question.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Apr 6, 2015
`Trait`, prefer the object. Also give a nice error for attempts to
manually `impl Trait for Trait`, since they will be ineffectual.

Fixes rust-lang#24015.

Fixes rust-lang#24051.
Fixes rust-lang#24037.
Fixes rust-lang#23853.
Fixes rust-lang#21942.
cc rust-lang#21756.
bors added a commit that referenced this issue Apr 6, 2015
If we find a blanket impl for `Trait` but we're matching on an object `Trait`, prefer the object (I think we could perhaps go either way, but this seems safer). Also give a nice error for attempts to manually `impl Trait for Trait`, since they will be ineffectual.

This fixes the problems around ambiguity ICEs relating to `Any` and `MarkerTrait` that were cropping up all over the place. There may still be similar ICEs reported in #21756 that this PR does not address.

Fixes #24015.

Fixes #24051.
Fixes #24037.
Fixes #23853.
Fixes #21942.
cc #21756.

cc @alexcrichton (this fixes crates.io)
r? @aturon
@pmarcelll
Copy link
Contributor

Seems to be fixed:

test.rs:5:1: 9:2 error: the object type `MyTrait + 'a` automatically implements the trait `MyTrait` [E0371]
test.rs:5 impl<'a> MyTrait for MyTrait + 'a {
test.rs:6     fn do_something(&self) {
test.rs:7         println!("MyTrait");
test.rs:8     }
test.rs:9 }
test.rs:5:1: 9:2 help: run `rustc --explain E0371` to see a detailed explanation
error: aborting due to previous error

@alexcrichton
Copy link
Member

Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests