rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.87k stars 12.77k forks source link

ICE compiling libcore with RUST_LOG=debug #22187

Closed aidancully closed 9 years ago

aidancully commented 9 years ago

build command:

RUST_BACKTRACE=1 RUST_LOG=debug CFG_LLVM_LINKAGE_FILE=/usr/home/aidan/rust/aidancully/rust/x86_64-unknown-freebsd/rt/llvmdeps.rs LD_LIBRARY_PATH=/usr/home/aidan/rust/aidancully/rust/x86_64-unknown-freebsd/stage0/lib:/pkg/rust/lib: x86_64-unknown-freebsd/stage0/bin/rustc --cfg stage0 -O --cfg rtopt --cfg debug -C prefer-dynamic --target=x86_64-unknown-freebsd -D warnings -L x86_64-unknown-freebsd/rt -L /usr/home/aidan/rust/aidancully/rust/x86_64-unknown-freebsd/llvm/Release+Asserts/lib -L "" --out-dir x86_64-unknown-freebsd/stage0/lib/rustlib/x86_64-unknown-freebsd/lib -C extra-filename=-4e7c5e5c /usr/home/aidan/rust/aidancully/rust/src/libcore/lib.rs

output tail:

DEBUG:rustc_typeck::astconv: ast_ty_to_ty(ast_ty=type(Self))
DEBUG:rustc::middle::ty_walk: next(): stack=[TyS { sty: ty_param(ParamTy { space: SelfSpace, idx: 0, name: "Self"(10) 
}), flags: 2, region_depth: 0 }]
DEBUG:rustc::middle::ty_walk: next: stack=[]
DEBUG:rustc::middle::ty_walk: next(): stack=[]
DEBUG:rustc_typeck::collect: ty_generics: def for type param: TypeParameterDef(DefId { krate: 0, node: 28888 }, Sized,
 TypeSpace/0), TypeSpace
DEBUG:rustc::middle::ty: Interned type: TyS { sty: ty_projection(ProjectionTy { trait_ref: TraitRef { def_id: DefId { 
krate: 0, node: 28875 }, substs: Substs { types: VecPerParamSpace {TypeSpace: [TyS { sty: ty_param(ParamTy { space: Ty
peSpace, idx: 0, name: "RHS"(2016) }), flags: 1, region_depth: 0 }], SelfSpace: [TyS { sty: ty_param(ParamTy { space: 
SelfSpace, idx: 0, name: "Self"(10) }), flags: 2, region_depth: 0 }], FnSpace: [], }, regions: NonerasedRegions(VecPer
ParamSpace {TypeSpace: [], SelfSpace: [], FnSpace: [], }) } }, item_name: "Output"(662) }), flags: 131, region_depth: 
0 } Pointer: 0x80515f3c8
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
thread 'rustc' panicked at 'assertion failed: did.krate != ast::LOCAL_CRATE', /usr/home/rustbuild/src/rust-buildbot/sl
ave/snap3-bsd/build/src/librustc/middle/ty.rs:5342

stack backtrace:
   1:          0x1fcd2d0 - sys::backtrace::write::ha1d57a9df5a2f693fqy
   2:          0x1fdb2e0 - failure::on_fail::hfce282f973673675zJF
   3:          0x1f954f0 - rt::unwind::begin_unwind_inner::ha66af0dd4f8827bcxnF
   4:           0x947460 - rt::unwind::begin_unwind::h1827019987828831768
   5:           0xc6e4e0 - middle::ty::lookup_trait_def::ha7feab3e197f1950VQ7
   6:           0xbaba60 - util::ppaux::ty..TraitRef<'tcx>.Repr<'tcx>::repr::h33b020d33af3b28apsw
   7:           0xc668c0 - util::ppaux::ty..TraitPredicate<'tcx>.Repr<'tcx>::repr::hbf74eab3dd3fbda5iIx
   8:           0xc667f0 - util::ppaux::ty..Binder<T>.Repr<'tcx>::repr::h18078159607407995581
   9:           0xc71ff0 - middle::ty::ty..Predicate<'tcx>.Repr<'tcx>::repr::h8ba7c61308cdb541KE9
  10:           0x7731d0 - util::ppaux::repr_vec::h15939608278100118170
  11:           0x843680 - collect::trait_def_of_item::h00641e27aab43d5eLPw
  12:           0x8538f0 - collect::CollectCtxt<'a, 'tcx>.AstConv<'tcx>::get_trait_def::hdda578395178a444g5v
  13:           0x82d220 - astconv::ast_path_to_trait_ref::h5a8e2311a51c406bNqu
  14:           0x7dd290 - astconv::instantiate_trait_ref::hac5260b61ea589f2unu
  15:           0x82cc60 - astconv::instantiate_poly_trait_ref::h794f45e24e531b40Zlu
  16:           0x85d970 - collect::compute_bounds::h7618fc0c60b4ede29ux
  17:           0x843680 - collect::trait_def_of_item::h00641e27aab43d5eLPw
  18:           0x842c50 - collect::CollectTraitDefVisitor<'a, 'tcx>.visit..Visitor<'v>::visit_item::h99bfd5c22238fb9eC0v
  19:           0x842c50 - collect::CollectTraitDefVisitor<'a, 'tcx>.visit..Visitor<'v>::visit_item::h99bfd5c22238fb9eC0v
  20:           0x883f30 - check_crate::closure.34427
  21:           0x881a00 - check_crate::h86a876ef1ca89126ZKA
  22:           0x4646c0 - driver::phase_3_run_analysis_passes::h57367842623679e7pGa
  23:           0x44a2e0 - driver::compile_input::hc2766520ac97d2dfCba
  24:           0x51e220 - run_compiler::h7c28b9751d19b5c87ac
  25:           0x51c8b0 - thunk::F.Invoke<A, R>::invoke::h14453603883644514953
  26:           0x51b600 - rt::unwind::try::try_fn::h11398371315295182304
  27:          0x1fe07d0 - rust_try_inner
  28:          0x1fe07c0 - rust_try
  29:           0x51b8b0 - thunk::F.Invoke<A, R>::invoke::h14165555330071885221
  30:          0x1fd99b0 - sys::thread::thread_start::hc2c3539848b3238eUvB
  31:        0x802a7bc30 - <unknown>
  32:                0x0 - <unknown>

I isolated the problem to this line in librustc_typeck/collect.rs:

    debug!("ty_generics_for_trait: assoc_predicates={}", assoc_predicates.repr(ccx.tcx));

In this case, the assoc_predicates for a type are defined in the local crate (it's libcore, and the associated predicate is ?Sized), so the lookup_trait_def assertion trips.

pnkfelix commented 9 years ago

Here is a smaller test case (using no_std) to reproduce this:

#![feature(no_std)]
#![feature(lang_items)]
#![crate_type="lib"]
#![no_std]

#[lang="sized"]
pub trait Sized { }

trait T {
    type Ty;
}

And then build it like so:

% RUST_LOG=debug ./x86_64-apple-darwin/stage1/bin/rustc /tmp/issue22187.rs > /tmp/issue22187.log 2>&1
[ERROR#1] %
aidancully commented 9 years ago

I rechecked my patch more rigorously, and it looks like this was resolved by a6c295cb22d4c76c0b58a7f0fbca104b7dcbfdc4. I'm closing this issue.