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 rustc::util::ppaux when trying to represent a TraitRef #19978

Closed
Munksgaard opened this issue Dec 18, 2014 · 1 comment · Fixed by #19979
Closed

ICE in rustc::util::ppaux when trying to represent a TraitRef #19978

Munksgaard opened this issue Dec 18, 2014 · 1 comment · Fixed by #19979

Comments

@Munksgaard
Copy link
Contributor

The following code gives an ICE when compiled with "RUST_LOG=rustc::middle::ty"

// foo.rs
use std::thunk::Invoke;

fn foo(x: Box<for <'a>Invoke<&'a int, ()>>) {
}

fn bar() {
    foo( box () (move |: _| () ))
}

fn main() {
}

Terminal output:

$ RUST_LOG=rustc::middle::ty rustc foo.rs 
[snip]
DEBUG:rustc::middle::ty_fold: RegionFolder.fold_region(ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(DefId { krate: 0, node: 11 }, 'a))) folding free region (current_depth=1)
DEBUG:rustc::middle::ty: region=ReLateBound(DebruijnIndex { depth: 1 }, BrNamed(DefId { krate: 0, node: 11 }, 'a))
DEBUG:rustc::middle::ty_fold: RegionFolder.fold_region('_#1r) folding free region (current_depth=1)
DEBUG:rustc::middle::ty: region='_#1r
DEBUG:rustc::middle::ty: resulting map: {BrNamed(DefId { krate: 0, node: 11 }, "'a"(67)): ReInfer(ReSkolemized(1, BrNamed(DefId { krate: 0, node: 11 }, "'a"(67))))} value: <closure[ppaux-trait.rs:12:23: 12:33] : rustrt::thunk::Invoke<&'a int>>
DEBUG:rustc::util::ppaux: In here?, strs: [_, _]
error: internal compiler error: unexpected panic
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
task 'rustc' panicked at 'assertion failed: begin <= end', /home/munksgaard/src/rust/src/libcore/str.rs:1987

stack backtrace:
   1:     0x7f4e89d36bf0 - rt::backtrace::imp::write::h753c38a2430ca467LXx
   2:     0x7f4e89d38ea0 - failure::on_fail::h19efc28aec0762558oy
   3:     0x7f4e8998f130 - unwind::begin_unwind_inner::hf57a521c78af8176aNc
   4:     0x7f4e8998ed40 - unwind::begin_unwind_fmt::h786920ac23251d41xKc
   5:     0x7f4e8998ed00 - rust_begin_unwind
   6:     0x7f4e899d61e0 - panicking::panic_fmt::ha079646168f8412dVul
   7:     0x7f4e899d3ee0 - panicking::panic::h30cadc68e2188145lsl
   8:     0x7f4e899dfdf0 - str::slice_error_fail::h169a2f1d1b3525edU2s
   9:     0x7f4e86e871c0 - str::str.StrPrelude::slice::h871c83e51e3204cakat
  10:     0x7f4e87314a30 - str::traits::str.ops..Slice<uint, str>::slice_or_fail::he2e6d7fdf110a1d3OSs
  11:     0x7f4e873149a0 - string::String.ops..Slice<uint, str>::slice_or_fail::hb838c421a94a331dAjl
  12:     0x7f4e8730ef00 - util::ppaux::parameterized::h0357a9c8dd2f0f65ZWz
  13:     0x7f4e86c002c0 - util::ppaux::ty..TraitRef<'tcx>.Repr<'tcx>::repr::h36e5448c7a73849cQoA
  14:     0x7f4e86cd94d0 - middle::ty::replace_late_bound_regions::h1531858869964127734
  15:     0x7f4e86cd9450 - middle::infer::InferCtxt<'a, 'tcx>::replace_late_bound_regions_with_fresh_var::h12622384554465029402
  16:     0x7f4e86cd7ae0 - middle::infer::higher_ranked::C.HigherRankedRelations<'tcx>::higher_ranked_sub::h13202814231754868156
  17:     0x7f4e86b99ad0 - middle::infer::sub::Sub<'f, 'tcx>.Combine<'tcx>::trait_refs::h8f79251ad60f36b0FNy
  18:     0x7f4e86cfeff0 - middle::infer::InferCtxt<'a, 'tcx>::sub_trait_refs::unboxed_closure.82051
  19:     0x7f4e86cfeed0 - middle::infer::InferCtxt<'a, 'tcx>::commit_if_ok::unboxed_closure.82047
  20:     0x7f4e86cfe8a0 - middle::infer::InferCtxt<'a, 'tcx>::try::h13041868228909284202
  21:     0x7f4e86cfe810 - middle::infer::InferCtxt<'a, 'tcx>::commit_if_ok::unboxed_closure.82043
  22:     0x7f4e86cfe4c0 - middle::infer::InferCtxt<'a, 'tcx>::commit_unconditionally::h9957937110058402482
  23:     0x7f4e86cfe420 - middle::infer::InferCtxt<'a, 'tcx>::commit_if_ok::h18311147822187977066
  24:     0x7f4e86cf1e70 - middle::infer::InferCtxt<'a, 'tcx>::sub_trait_refs::he0811510b107a039cgB
  25:     0x7f4e86f773d0 - middle::traits::select::SelectionContext<'cx, 'tcx>::match_trait_refs::hf14282dc65e45a572o0
  26:     0x7f4e86f62ae0 - middle::traits::select::SelectionContext<'cx, 'tcx>::match_impl::h05760caf93362a5cBm0
  27:     0x7f4e86f7cdf0 - middle::traits::select::SelectionContext<'cx, 'tcx>::assemble_candidates_from_impls::unboxed_closure.87090
  28:     0x7f4e86f7caf0 - middle::infer::InferCtxt<'a, 'tcx>::probe::h2528939993133769717
  29:     0x7f4e86f72dc0 - middle::traits::select::SelectionContext<'cx, 'tcx>::assemble_candidates_from_impls::hb9747ff2e6f9d927MoZ
  30:     0x7f4e86f67010 - middle::traits::select::SelectionContext<'cx, 'tcx>::assemble_candidates::h3a71044df78cef2eI7Y
  31:     0x7f4e86f65990 - middle::traits::select::SelectionContext<'cx, 'tcx>::candidate_from_obligation_no_cache::hd8527b024bba7ec8KTY
  32:     0x7f4e86f5a560 - middle::traits::select::SelectionContext<'cx, 'tcx>::candidate_from_obligation::h7ca9927d5d40cb08jLY
  33:     0x7f4e86f4d7f0 - middle::traits::select::SelectionContext<'cx, 'tcx>::select::hae1bcf878e08d30d5qY
  34:     0x7f4e86f44f30 - middle::traits::fulfill::process_predicate::h76dde3b8f41fc28bVXX
  35:     0x7f4e86f44370 - middle::traits::fulfill::FulfillmentContext<'tcx>::select::unboxed_closure.86282
  36:     0x7f4e86f44120 - vec::Vec<T>::retain::h12279568420075653578
  37:     0x7f4e86f42590 - middle::traits::fulfill::FulfillmentContext<'tcx>::select::hc06be6e4b3591c31vQX
  38:     0x7f4e86f42440 - middle::traits::fulfill::FulfillmentContext<'tcx>::select_new_obligations::h91c5682dcecb9c75JOX
  39:     0x7f4e887a3310 - check::vtable::select_new_fcx_obligations::h26663844ebbab5d5qEb
  40:     0x7f4e88afd0c0 - check::check_argument_types::he3bd55f5588b1cc173m
  41:     0x7f4e88b11980 - check::check_expr_with_unifier::check_call::ha2d73a7c93c60093XEn
  42:     0x7f4e88b51380 - check::check_expr_with_unifier::h14142777338591582923
  43:     0x7f4e88b013c0 - check::check_expr_coercable_to_type::h544f7bae172a45e6Kqn
  44:     0x7f4e88a45850 - check::check_block_with_expected::h812e5093bbaf2439uxp
  45:     0x7f4e889ddf50 - check::check_fn::h7810879eb70097d16qk
  46:     0x7f4e88a2bf90 - check::check_bare_fn::h139ac4d72cf0f50bxgk
  47:     0x7f4e88a22b30 - check::check_item::haee6d627fb09d78aXzk
  48:     0x7f4e88a22ad0 - check::CheckItemTypesVisitor<'a, 'tcx>.Visitor<'v>::visit_item::h9f212988ea8765dcwek
  49:     0x7f4e88a29560 - visit::walk_mod::h8035559567414864198
  50:     0x7f4e88a29510 - visit::Visitor::visit_mod::h11259418057042546077
  51:     0x7f4e88a2b880 - visit::walk_crate::h14105224974318518012
  52:     0x7f4e88a2b6d0 - check::check_item_types::h3a818764d13a5fc3Hfk
  53:     0x7f4e891b71a0 - check_crate::unboxed_closure.42684
  54:     0x7f4e891b6d60 - util::common::time::h12563125154392974828
  55:     0x7f4e891b4070 - check_crate::h7b7df8bc37ab8e8ad7y
  56:     0x7f4e8a18d270 - driver::phase_3_run_analysis_passes::h5a3f3baf975d5d5eEta
  57:     0x7f4e8a164c30 - driver::compile_input::h8544a98e233f0cd0rba
  58:     0x7f4e8a6bd350 - run_compiler::ha964b5661755640aAYb
  59:     0x7f4e8a6a6450 - run::unboxed_closure.29622
  60:     0x7f4e8a6a3a30 - task::TaskBuilder::try_future::unboxed_closure.29603
  61:     0x7f4e8a6a39a0 - thunk::Thunk<(*, R>::new::unboxed_closure.29600
  62:     0x7f4e8a6a38b0 - thunk::F.Invoke<A, R>::invoke::h5540669155237377224
  63:     0x7f4e89d14760 - thunk::F.Invoke<A, R>::invoke::h8883895553215660696
  64:     0x7f4e8998dd90 - task::Task::spawn_thunk::closure.5799
  65:     0x7f4e899eaee0 - rust_try_inner
  66:     0x7f4e899eaed0 - rust_try
  67:     0x7f4e8998dc90 - task::Task::run::h45bc2e5c96c4ea9btNb
  68:     0x7f4e8998d660 - thunk::F.Invoke<A, R>::invoke::h4673927346077986474
  69:     0x7f4e8998e9c0 - thread::thread_start::h947b45e879731c8eM4b
  70:     0x7f4e83150160 - start_thread
  71:     0x7f4e8966dc69 - __clone
  72:                0x0 - <unknown>

Rust version:

$ rustc --version 
rustc 0.13.0-dev (22a9f250b 2014-12-17 21:33:15 +0000)

It should be noted, that the above code still produces the ICE in #19919 when compiled without RUST_LOG.

@Munksgaard
Copy link
Contributor Author

This is caused by 570325d. Patch underway.

Munksgaard added a commit to Munksgaard/rust that referenced this issue Dec 19, 2014
This fixes rust-lang#19978. The bug was introduced by 570325d, where if the type
of an Fn has not been inferred (strs[0] is "_") we slice from 1 to
0. We now explicitly check if `strs[0]` is a single element tuple.
alexcrichton added a commit to alexcrichton/rust that referenced this issue Dec 21, 2014
This fixes rust-lang#19978. The bug was introduced by 570325d, where if the type
of an Fn has not been inferred (strs[0] is "_") we slice from 1 to 0.
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.

1 participant