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

rustc_driver: Catch ICEs on the main thread too #49826

Merged
merged 1 commit into from
Apr 28, 2018

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Apr 10, 2018

#48575 introduced an optimization to run rustc directly on the main thread when possible. However, the threaded code detects panics when they join() to report as an ICE. When running directly, we need to use panic::catch_unwind to get the same effect.

cc @ishitatsuyuki
r? @alexcrichton

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 10, 2018
@alexcrichton
Copy link
Member

@bors: r+

Thanks!

@bors
Copy link
Contributor

bors commented Apr 10, 2018

📌 Commit 6742795 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 10, 2018
@kennytm
Copy link
Member

kennytm commented Apr 11, 2018

This seems to cause rollup to fail in #49875 (comment) after merging with the latest master. Could you verify if this is the case after rebasing?

@cuviper
Copy link
Member Author

cuviper commented Apr 11, 2018

I will verify, but I doubt this would cause such a problem. The only difference should be whether a compiler panic also reports the ICE message.

@cuviper
Copy link
Member Author

cuviper commented Apr 11, 2018

Weird! That test is fine on master (two expected errors and a clean exit), but it does indeed panic with just my patch rebased on top. I really don't understand why!

$ RUST_BACKTRACE=1 rustc +dev2 -Z continue-parse-after-error src/test/compile-fail/issue-36638.rs
error: expected identifier, found keyword `Self`
  --> src/test/compile-fail/issue-36638.rs:13:12
   |
13 | struct Foo<Self>(Self);
   |            ^^^^ expected identifier, found keyword

error: expected identifier, found keyword `Self`
  --> src/test/compile-fail/issue-36638.rs:16:11
   |
16 | trait Bar<Self> {}
   |           ^^^^ expected identifier, found keyword

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`', librustc/ty/sty.rs:889:13
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic_fmt
   7: rustc::ty::sty::ParamTy::is_self
   8: rustc::ty::flags::FlagComputation::for_sty
   9: rustc::ty::context::CtxtInterners::intern_ty
  10: rustc::ty::subst::<impl rustc::ty::Slice<rustc::ty::subst::Kind<'tcx>>>::fill_item
  11: rustc::ty::subst::<impl rustc::ty::Slice<rustc::ty::subst::Kind<'tcx>>>::identity_for_item
  12: rustc_typeck::collect::predicates_of
  13: rustc::ty::maps::<impl rustc::ty::maps::queries::predicates_of<'tcx>>::compute_result
  14: rustc::dep_graph::graph::DepGraph::with_task_impl
  15: rustc::ty::context::tls::with_related_context
  16: rustc::ty::maps::<impl rustc::ty::maps::queries::predicates_of<'tcx>>::force_with_lock
  17: rustc::ty::maps::<impl rustc::ty::maps::queries::predicates_of<'tcx>>::try_get
  18: rustc::ty::maps::TyCtxtAt::predicates_of
  19: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::predicates_of
  20: <rustc_typeck::collect::CollectItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  21: rustc::hir::Crate::visit_all_item_likes
  22: rustc::session::Session::track_errors
  23: rustc_typeck::check_crate
  24: rustc::ty::context::tls::enter_context
  25: <std::thread::local::LocalKey<T>>::with
  26: rustc::ty::context::TyCtxt::create_and_enter
  27: rustc_driver::driver::compile_input
  28: rustc_driver::run_compiler_impl
  29: syntax::with_globals
  30: std::panicking::try::do_call
  31: __rust_maybe_catch_panic
  32: rustc_driver::main
  33: std::rt::lang_start::{{closure}}
  34: std::panicking::try::do_call
  35: __rust_maybe_catch_panic
  36: std::rt::lang_start_internal
  37: main
  38: __libc_start_main
  39: _start
query stack during panic:
#0 [predicates_of] processing `Bar`
  --> src/test/compile-fail/issue-36638.rs:16:1
   |
16 | trait Bar<Self> {}
   | ^^^^^^^^^^^^^^^
end of query stack
error: aborting due to 2 previous errors


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: rustc 1.27.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z continue-parse-after-error

@kennytm
Copy link
Member

kennytm commented Apr 11, 2018

Thanks for verification! Let me take this off the queue first then.

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 11, 2018
@cuviper
Copy link
Member Author

cuviper commented Apr 11, 2018

That test is fine on master (two expected errors and a clean exit),

I take that back! The test does "pass" on master, but wrongly so -- it's not actually clean.

In compiletest's check_no_compiler_crash it only looks for "error: internal compiler error". Before my patch, you get the panic without the ICE message, so the crash is not noticed!

$ RUST_BACKTRACE=1 rustc +dev2 -Z continue-parse-after-error src/test/compile-fail/issue-36638.rs
error: expected identifier, found keyword `Self`
  --> src/test/compile-fail/issue-36638.rs:13:12
   |
13 | struct Foo<Self>(Self);
   |            ^^^^ expected identifier, found keyword

error: expected identifier, found keyword `Self`
  --> src/test/compile-fail/issue-36638.rs:16:11
   |
16 | trait Bar<Self> {}
   |           ^^^^ expected identifier, found keyword

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`', librustc/ty/sty.rs:889:13
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic_fmt
   7: rustc::ty::sty::ParamTy::is_self
   8: rustc::ty::flags::FlagComputation::for_sty
   9: rustc::ty::context::CtxtInterners::intern_ty
  10: rustc::ty::subst::<impl rustc::ty::Slice<rustc::ty::subst::Kind<'tcx>>>::fill_item
  11: rustc::ty::subst::<impl rustc::ty::Slice<rustc::ty::subst::Kind<'tcx>>>::identity_for_item
  12: rustc_typeck::collect::predicates_of
  13: rustc::ty::maps::<impl rustc::ty::maps::queries::predicates_of<'tcx>>::compute_result
  14: rustc::dep_graph::graph::DepGraph::with_task_impl
  15: rustc::ty::context::tls::with_related_context
  16: rustc::ty::maps::<impl rustc::ty::maps::queries::predicates_of<'tcx>>::force_with_lock
  17: rustc::ty::maps::<impl rustc::ty::maps::queries::predicates_of<'tcx>>::try_get
  18: rustc::ty::maps::TyCtxtAt::predicates_of
  19: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::predicates_of
  20: <rustc_typeck::collect::CollectItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  21: rustc::hir::Crate::visit_all_item_likes
  22: rustc::session::Session::track_errors
  23: rustc_typeck::check_crate
  24: rustc::ty::context::tls::enter_context
  25: <std::thread::local::LocalKey<T>>::with
  26: rustc::ty::context::TyCtxt::create_and_enter
  27: rustc_driver::driver::compile_input
  28: rustc_driver::run_compiler_impl
  29: syntax::with_globals
  30: rustc_driver::main
  31: std::rt::lang_start::{{closure}}
  32: std::panicking::try::do_call
  33: __rust_maybe_catch_panic
  34: std::rt::lang_start_internal
  35: main
  36: __libc_start_main
  37: _start
query stack during panic:
#0 [predicates_of] processing `Bar`
  --> src/test/compile-fail/issue-36638.rs:16:1
   |
16 | trait Bar<Self> {}
   | ^^^^^^^^^^^^^^^
end of query stack
error: aborting due to 2 previous errors

@abonander
Copy link
Contributor

Is there something blocking this? compiletest is eating ICEs in other compile-fail tests as well.

@cuviper cuviper added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 20, 2018
@cuviper
Copy link
Member Author

cuviper commented Apr 20, 2018

It won't pass CI until #49889 is fixed, at least.

@cuviper
Copy link
Member Author

cuviper commented Apr 27, 2018

Rebased now that #49891 is merged, including its fixes for the failures that had snuck into the tree.

@cuviper cuviper added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Apr 27, 2018
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Apr 27, 2018

📌 Commit 64bcbca has been approved by alexcrichton

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 27, 2018
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Apr 27, 2018
@bors
Copy link
Contributor

bors commented Apr 28, 2018

⌛ Testing commit 64bcbca with merge 24d49ea97e9b53a9aa14e67988a6388c6add1494...

@bors
Copy link
Contributor

bors commented Apr 28, 2018

💔 Test failed - status-appveyor

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 28, 2018
@kennytm
Copy link
Member

kennytm commented Apr 28, 2018

@bors retry #42117

x86_64-msvc-cargo, failed to check out servo/webrender.

testing https://github.com/servo/webrender
Initialized empty Git repository in /c/projects/rust/build/ct/webrender/.git/
fatal: Could not parse object '57250b2b8fa63934f80e5376a29f7dcb3f759ad6'.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 28, 2018
@bors
Copy link
Contributor

bors commented Apr 28, 2018

⌛ Testing commit 64bcbca with merge 207bc40...

bors added a commit that referenced this pull request Apr 28, 2018
rustc_driver: Catch ICEs on the main thread too

#48575 introduced an optimization to run rustc directly on the main thread when possible.  However, the threaded code detects panics when they `join()` to report as an ICE.  When running directly, we need to use `panic::catch_unwind` to get the same effect.

cc @ishitatsuyuki
r? @alexcrichton
@bors
Copy link
Contributor

bors commented Apr 28, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 207bc40 to master...

@bors bors merged commit 64bcbca into rust-lang:master Apr 28, 2018
@cuviper cuviper deleted the rustc-main-ICE branch May 4, 2018 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants