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 Creader::resolve_crate() when resolving unknown crate from metadata #40535

Closed
abonander opened this issue Mar 15, 2017 · 11 comments
Closed
Assignees
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@abonander
Copy link
Contributor

rustc 1.17.0-nightly (6f10e2f63 2017-03-14)

Backtrace and last log statement before panic:

INFO:rustc_metadata::creader: resolving crate `extern crate rayon as rayon`
error: internal compiler error: unexpected panic

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

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:323
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: rustc_metadata::creader::CrateLoader::resolve_crate
   1: <rustc_metadata::creader::CrateLoader<'a> as rustc::middle::cstore::CrateLoader>::process_item
   2: rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver<'a>>::build_reduced_graph_for_item
   3: <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item
   4: <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item
   5: rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::visit_expansion
   6: syntax::ext::expand::MacroExpander::collect_invocations
   7: syntax::ext::expand::MacroExpander::expand
   8: syntax::ext::expand::MacroExpander::expand_crate
   9: rustc_driver::driver::phase_2_configure_and_expand::{{closure}}
  10: rustc_driver::driver::phase_2_configure_and_expand
  11: rustc_driver::driver::compile_input
  12: rustc_driver::run_compiler
  13: std::panicking::try::do_call
  14: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  15: <F as alloc::boxed::FnBox<A>>::call_box
  16: std::sys::imp::thread::Thread::new::thread_start
             at /checkout/src/liballoc/boxed.rs:650
             at /checkout/src/libstd/sys_common/thread.rs:21
             at /checkout/src/libstd/sys/unix/thread.rs:84
  17: start_thread
  18: clone

error: Could not compile `img-dup`.

To learn more, run the command again with --verbose.

I have the code that caused the ICE (including Cargo.lock) branched off here: https://github.com/abonander/img-dup/tree/ice_mar_2017

@jseyfried I'd like to work on this one, first step will be to attempt building with a debug-mode rustc to get the exact line number.

@jseyfried
Copy link
Contributor

jseyfried commented Mar 15, 2017

@abonander Great! Is this a regression?

@abonander
Copy link
Contributor Author

Not sure, let me check.

@abonander
Copy link
Contributor Author

@jseyfried Looks like a beta-to-nightly. On stable and beta I get a regular old "cannot find crate rayon" because it wasn't in my Cargo deps.

@jseyfried jseyfried self-assigned this Mar 15, 2017
@jseyfried jseyfried added 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. labels Mar 15, 2017
@abonander abonander changed the title ICE in Creader::resolve_crate() when resolving rayon ICE in Creader::resolve_crate() when resolving unknown crate Mar 15, 2017
@jseyfried
Copy link
Contributor

Thanks! Self-assigning so I don't forget about this.
My first step would be to figure out what PR caused this -- I'll do that this weekend unless you figure it out first :)

@abonander
Copy link
Contributor Author

Seems it's a little more complicated than I first expected. I use cargo check frequently to make sure my project compiles without wasting time in trans, and it seems that that's significant, because cargo build works fine on nightly (correctly reports the unknown crate error). cargo check also ICEs on rustc 1.17.0-beta.1 (408d49e60 2017-03-14), but on stable it instead prints an error about invalid arguments to rustc.

So this may be due to argument parsing changes instead of changes in Creader, or an unfortunate interaction of such changes, but it also appears to be a stable-to-beta regression since stable doesn't ICE. I initially thought it was a beta-to-nightly regression because beta initially printed the same error as stable, but my beta was outdated and it ICEs after updating.

@abonander
Copy link
Contributor Author

I guess it's back to metadata because the arguments don't appear malformed, cargo check is just having rustc emit rmeta's instead of rlib's: https://gist.github.com/abonander/a1b7df5cde0be49e1fc4cbf604771023

So... stable-beta regression of metadata loading, I guess?

@abonander abonander changed the title ICE in Creader::resolve_crate() when resolving unknown crate ICE in Creader::resolve_crate() when resolving unknown crate from metadata Mar 15, 2017
@jseyfried jseyfried added regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Mar 15, 2017
@jseyfried
Copy link
Contributor

cc @nrc

@TimNN
Copy link
Contributor

TimNN commented Mar 15, 2017

Maybe related: #40469

@abonander
Copy link
Contributor Author

Found the problematic unwrap() by replacing it with expect(), it was my first suspect too: https://github.com/rust-lang/rust/blob/master/src/librustc_metadata/creader.rs#L238

My first instinct is to just add an .or(source.rmeta.as_ref()) there but I don't think it's that simple; it shouldn't be getting this far with a nonexistent crate, should it?

@abonander
Copy link
Contributor Author

Wow, I guess it was that simple. I don't get the ICE anymore. PR incoming.

@abonander
Copy link
Contributor Author

Minimal reproduction case: https://github.com/abonander/rust-issue-40535

abonander added a commit to abonander/rust that referenced this issue Mar 18, 2017
alexcrichton pushed a commit to alexcrichton/rust that referenced this issue Mar 20, 2017
retep998 pushed a commit to abonander/rust that referenced this issue Mar 21, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Mar 23, 2017
Correctly get source for metatdata-only crate type

Closes rust-lang#40535

However, I'm not sure how to approach writing a regression test since I'm still working on a reduced test case from the code that caused the ICE in the first place. It's not enough to have an unknown `extern crate` in a metadata crate, it depends on a few extra arguments but I'm not sure which yet.

Also replaced the `unwrap()` with a more informative `expect()`.

r? @jseyfried
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta. 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

3 participants