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 with cross-crate projection #37291

Closed
physhh opened this Issue Oct 19, 2016 · 9 comments

Comments

Projects
None yet
6 participants
@physhh
Copy link

physhh commented Oct 19, 2016

Running rustdoc all testcases for this crate fails with an ICE. The relevant testcase is currently disabled. To enable it go to image/impl_core.rs:24 and remove the ignore marker.

rustc --version --verbose:

rustc 1.14.0-nightly (16eeeac78 2016-10-18)
binary: rustc
commit-hash: 16eeeac783d2ede28e09f2a433c612dea309fe33
commit-date: 2016-10-18
host: x86_64-pc-windows-msvc
release: 1.14.0-nightly
LLVM version: 3.9

This is the result of cargo test:

    Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
     Running target\debug\deps\img-7ec732e017a2f5eb.exe

running 4 tests
test px::test_arithmetic ... ok
test px::test_raw_buffer_funcs ... ok
test scalar::test_arithmetic ... ok
test image::test_image_buffer ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured

   Doc-tests img

running 8 tests
test px::generic::PixelArithmetic_0 ... ok
test image::generics::Image_0 ... ok
test image::impl_core::ImageVal_0 ... FAILED
test px::generic::Pixel::calc_minimum_pitch_0 ... ok
test px::generic::Pixel_0 ... ok
test scalar::generic::Scalar_0 ... ok
test px::impl_core::PixelVal_0 ... ok
test scalar::impl_core::ScalarVal_0 ... ok

failures:

---- image::impl_core::ImageVal_0 stdout ----
        error: internal compiler error: ../src/librustc\traits\specialize/mod.rs:198: specializes: obligation `Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { trait_
ref: <_ as img::PixelArithmetic>, item_name: ScalarT(4511) }, _)),depth=1)` has inference types/regions

thread 'image::impl_core::ImageVal_0' panicked at 'Box<Any>', ../src/librustc_errors/lib.rs:656
stack backtrace:
   0:      0x7fee2c7f804 - <u32 as std::sys::IsZero>::is_zero::hb501b477ff597565
   1:      0x7fee2c7bca9 - std::panicking::Location::line::h756ee230b7a7fab3
   2:      0x7fee2c7c6ed - std::panicking::rust_panic_with_hook::hcd9d05f53fa0dafc
   3:      0x7fef3d128ea - <unknown>
   4:      0x7fef3d2608d - rustc_errors::Handler::bug::haca77c19c882b432
   5:      0x7fee197b2d5 - <rustc::util::ppaux::TraitAndProjections<'tcx> as core::fmt::Debug>::fmt::hb5d03a0e1370418a
   6:      0x7fee189b262 - rustc::session::bug_fmt::hde22f071bf5a80ea
   7:      0x7fee189af7c - rustc::session::bug_fmt::hde22f071bf5a80ea
   8:      0x7fee1975d31 - <rustc::util::ppaux::TraitAndProjections<'tcx> as core::fmt::Debug>::fmt::hb5d03a0e1370418a
   9:      0x7fee16c6dd7 - <unknown>
  10:      0x7fee19165d5 - rustc::ty::context::TyCtxt::free_region_map::h82e8c7df0d75ed07
  11:      0x7fee18d5cc6 - rustc::traits::specialize::specializes::hc06f881417f11f03
  12:      0x7fee18c8ae0 - rustc::traits::select::SelectionContext::evaluate_obligation_conservatively::h7dc149b5b7563089
  13:      0x7fee18c29da - rustc::traits::select::SelectionContext::evaluate_obligation_conservatively::h7dc149b5b7563089
  14:      0x7fee18c0da7 - rustc::traits::select::SelectionContext::evaluate_obligation_conservatively::h7dc149b5b7563089
  15:      0x7fee18c0430 - rustc::traits::select::SelectionContext::evaluate_obligation_conservatively::h7dc149b5b7563089
  16:      0x7fee18bfc9a - rustc::traits::select::SelectionContext::evaluate_obligation::h918f689b79ed78ea
  17:      0x7fee1da81e4 - rustc_typeck::check::method::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::lookup_method_in_trait_adjusted::h23bf843644a86a1c
  18:      0x7fee1dce0d8 - rustc_typeck::check::op::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_user_unop::hccfdc1643ed36810
  19:      0x7fee1dccd9c - rustc_typeck::check::op::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_binop::h5fef06b12193950d
  20:      0x7fee1dcc782 - rustc_typeck::check::op::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_binop::h5fef06b12193950d
  21:      0x7fee1dfa4ca - rustc_typeck::check::FnCtxt::check_struct_path::h0a3b8cb3a9a77f78
  22:      0x7fee1dfa066 - rustc_typeck::check::FnCtxt::check_struct_path::h0a3b8cb3a9a77f78
  23:      0x7fee1dfadf1 - rustc_typeck::check::FnCtxt::check_struct_path::h0a3b8cb3a9a77f78
  24:      0x7fee1dfa066 - rustc_typeck::check::FnCtxt::check_struct_path::h0a3b8cb3a9a77f78
  25:      0x7fee1e0accb - rustc_typeck::check::FnCtxt::check_stmt::he33c1a72110694ef
  26:      0x7fee1e0b1ca - rustc_typeck::check::FnCtxt::check_block_no_value::h45608011ee74f15e
  27:      0x7fee1dd5806 - <rustc_typeck::check::GatherLocalsVisitor<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_ty::hd4c15b543ae85d6e
  28:      0x7fee1dd38b0 - rustc_typeck::check::check_drop_impls::hf0fd3120466d7e2f
  29:      0x7fee1dd7f79 - rustc_typeck::check::check_item_body::h3223fb19b212e96a
  30:      0x7fee1dd072b - rustc_typeck::check::check_item_bodies::ha98a70a8fce7849f
  31:      0x7fee1e4f563 - rustc_typeck::check_crate::hd5386d41de8aa25b
  32:      0x7fee205b815 - <rustc_driver::Compilation as core::fmt::Debug>::fmt::hfc4845a68da21d3e
  33:      0x7fee1f8a06e - <unknown>
  34:      0x7fee2012353 - rustc_driver::driver::compile_input::h5b63ccd49eeeb98b
  35:      0x7fee2144800 - <unknown>
  36:      0x7fee2c81ce1 - _rust_maybe_catch_panic
  37:      0x7fee227755e - rustdoc::test::run::hcc44ccd17e8a0827
  38:      0x7fee2145a4f - <unknown>
  39:      0x7fee2c81ce1 - _rust_maybe_catch_panic
  40:      0x7fee5e63b4b - <unknown>
  41:      0x7fee2c81ce1 - _rust_maybe_catch_panic
  42:      0x7fee5e6b7fa - <unknown>
  43:      0x7fee2c79b2e - std::sys::thread::Thread::new::hf599b376c47e7cb9
  44:         0x76df59cc - BaseThreadInitThunk
thread 'image::impl_core::ImageVal_0' panicked at 'couldn't compile the test', ../src/librustdoc\test.rs:283
stack backtrace:
   0:      0x7fee2c7f804 - <u32 as std::sys::IsZero>::is_zero::hb501b477ff597565
   1:      0x7fee2c7bca9 - std::panicking::Location::line::h756ee230b7a7fab3
   2:      0x7fee2c7c6ed - std::panicking::rust_panic_with_hook::hcd9d05f53fa0dafc
   3:      0x7fee2142cd3 - <unknown>
   4:      0x7fee2278e14 - rustdoc::test::run::hcc44ccd17e8a0827
   5:      0x7fee2145a4f - <unknown>
   6:      0x7fee2c81ce1 - _rust_maybe_catch_panic
   7:      0x7fee5e63b4b - <unknown>
   8:      0x7fee2c81ce1 - _rust_maybe_catch_panic
   9:      0x7fee5e6b7fa - <unknown>
  10:      0x7fee2c79b2e - std::sys::thread::Thread::new::hf599b376c47e7cb9
  11:         0x76df59cc - BaseThreadInitThunk


failures:
    image::impl_core::ImageVal_0

test result: FAILED. 7 passed; 1 failed; 0 ignored; 0 measured

error: test failed

This fails on stable and nightly. I do not have time to create a reduced test case right now. Hope this helps anyway.

@TimNN

This comment has been minimized.

Copy link
Contributor

TimNN commented Oct 20, 2016

Regression from 1.9.0 to 1.10.0.

Requires the ice'ing code to be in a separate crate.

@TimNN

This comment has been minimized.

Copy link
Contributor

TimNN commented Oct 20, 2016

This was introduced between nightly-2016-05-10 and nightly-2016-05-12 (Changes). I suspect this was an effect of #33425.

I reduced the code some, although it can probably be reduced further, see https://gist.github.com/7cd880ff5d32b7de65c7910935d36d6e.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Oct 20, 2016

Thanks @TimNN !

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Oct 20, 2016

Reduced test cases wanted!

Nominating to get eyes on my compiler team.

@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented Oct 20, 2016

@rust-lang/compiler Does this look like any known lifetime-related bug that you can think of?

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Oct 20, 2016

Nothing that jumps to mind. I can try to dig in a bit.

@physhh

This comment has been minimized.

Copy link
Author

physhh commented Oct 20, 2016

Thanks for the effort so far!

I think this test case is easier to analyze: https://gist.github.com/physhh/0d4046b38940a309ce2b6e0ce516c4a9

Everytime I tried to further reduce the amount of types involved the ICE disappeared.

@TimNN

This comment has been minimized.

Copy link
Contributor

TimNN commented Oct 20, 2016

@physhh: Nice work!

I just remembered something I noticed while reducing the initial code:

Commenting out either one of the Mul impl's makes the ICE go away - irrespective of whether it is the one that applies in main.rs or not.

@nikomatsakis nikomatsakis self-assigned this Oct 20, 2016

@arielb1 arielb1 changed the title ICE while executing rustdoc test case ICE with cross-crate projection Oct 20, 2016

@arielb1 arielb1 removed the E-help-wanted label Oct 20, 2016

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Nov 2, 2016

Sorry for being slow to act on this. I am able to reproduce the problem. Investigating.

bors added a commit that referenced this issue Nov 3, 2016

Auto merge of #37541 - nikomatsakis:issue-37291, r=brson
Use impl obligations as initial environment for specialization

This corrects a small regression in specialization that crept in, I think as part of the refactoring to introduce arenas. I also made an experiment (in the last commit) to cleanup the code to be more aggressive about normalization. As the commit log notes, I am not 100% sure that this is correct, but it feels safer, and I think that at worst it yields *more* ICEs (as opposed to admitting faulty code). I'll schedule a crater run to check beyond the testbase.

Fixes #37291.

r? @aturon

@bors bors closed this in #37541 Nov 3, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.