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

[debug assertion] thread 'rustc' panicked at 'assertion failed: !value.has_escaping_bound_vars()' #70813

Closed
dwrensha opened this issue Apr 5, 2020 · 3 comments · Fixed by #72019
Assignees
Labels
A-inference Area: Type inference A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dwrensha
Copy link
Contributor

dwrensha commented Apr 5, 2020

Using a rustc built from commit 853c477 with debug assertions enabled (debug=true in config.toml), I'm seeing an internal compiler error on the following input (found by fuzz-rustc):

pub trait Foo {}
pub trait FooExt where for<'b> &'b &mut Self: Foo {}
impl<T> FooExt for T where for<'a> &'a mut T: Foo {}

fn main() {}
$ RUST_BACKTRACE=1 build/x86_64-unknown-linux-gnu/stage1/bin/rustc main.rs
error[E0637]: `&` without an explicit lifetime name cannot be used here
 --> main.rs:2:36
  |
2 | pub trait FooExt where for<'b> &'b &mut Self: Foo {}
  |                                    ^ explicit lifetime name needed here

thread 'rustc' panicked at 'assertion failed: !value.has_escaping_bound_vars()', src/librustc_middle/ty/sty.rs:877:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /home/dwrensha/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /home/dwrensha/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1439
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: <alloc::boxed::Box<F> as core::ops::function::Fn<A>>::call
             at ./src/liballoc/boxed.rs:1022
  11: rustc_driver::report_ice
             at src/librustc_driver/lib.rs:1175
  12: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:515
  13: std::panicking::begin_panic
             at ./src/libstd/panicking.rs:438
  14: rustc_middle::ty::sty::Binder<T>::dummy
             at src/librustc_middle/ty/sty.rs:877
  15: <rustc_middle::ty::ConstnessAnd<rustc_middle::ty::sty::TraitRef> as rustc_middle::ty::ToPredicate>::to_predicate
             at src/librustc_middle/ty/mod.rs:1478
  16: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::mk_obligation_for_def_id
             at src/librustc_trait_selection/traits/error_reporting/mod.rs:1309
  17: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt>::suggest_change_mut
             at src/librustc_trait_selection/traits/error_reporting/suggestions.rs:574
  18: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error
             at src/librustc_trait_selection/traits/error_reporting/mod.rs:399
  19: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
             at src/librustc_trait_selection/traits/error_reporting/mod.rs:1006
  20: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
             at src/librustc_trait_selection/traits/error_reporting/mod.rs:165
  21: rustc_typeck::check::FnCtxt::select_all_obligations_or_error
             at src/librustc_typeck/check/mod.rs:3512
  22: rustc_typeck::check::wfcheck::CheckWfFcxBuilder::with_fcx::{{closure}}
             at src/librustc_typeck/check/wfcheck.rs:54
  23: rustc_typeck::check::InheritedBuilder::enter::{{closure}}
             at src/librustc_typeck/check/mod.rs:659
  24: rustc_infer::infer::InferCtxtBuilder::enter::{{closure}}
             at ./src/librustc_infer/infer/mod.rs:595
  25: rustc_middle::ty::context::GlobalCtxt::enter_local::{{closure}}::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1527
  26: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1695
  27: rustc_middle::ty::context::tls::set_tlv
             at ./src/librustc_middle/ty/context.rs:1679
  28: rustc_middle::ty::context::tls::enter_context
             at ./src/librustc_middle/ty/context.rs:1695
  29: rustc_middle::ty::context::GlobalCtxt::enter_local::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1527
  30: rustc_middle::ty::context::tls::with_related_context::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1783
  31: rustc_middle::ty::context::tls::with_context::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1767
  32: rustc_middle::ty::context::tls::with_context_opt
             at ./src/librustc_middle/ty/context.rs:1756
  33: rustc_middle::ty::context::tls::with_context
             at ./src/librustc_middle/ty/context.rs:1767
  34: rustc_middle::ty::context::tls::with_related_context
             at ./src/librustc_middle/ty/context.rs:1780
  35: rustc_middle::ty::context::GlobalCtxt::enter_local
             at ./src/librustc_middle/ty/context.rs:1519
  36: rustc_infer::infer::InferCtxtBuilder::enter
             at ./src/librustc_infer/infer/mod.rs:594
  37: rustc_typeck::check::InheritedBuilder::enter
             at src/librustc_typeck/check/mod.rs:659
  38: rustc_typeck::check::wfcheck::CheckWfFcxBuilder::with_fcx
             at src/librustc_typeck/check/wfcheck.rs:45
  39: rustc_typeck::check::wfcheck::check_impl
             at src/librustc_typeck/check/wfcheck.rs:600
  40: rustc_typeck::check::wfcheck::check_item_well_formed
             at src/librustc_typeck/check/wfcheck.rs:123
  41: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_item_well_formed>::compute
             at ./src/librustc_middle/ty/query/plumbing.rs:357
  42: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
             at ./src/librustc_query_system/dep_graph/graph.rs:303
  43: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
             at ./src/librustc_query_system/dep_graph/graph.rs:200
  44: rustc_query_system::query::plumbing::force_query_with_job::{{closure}}::{{closure}}
             at ./src/librustc_query_system/query/plumbing.rs:592
  45: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}
             at ./src/librustc_middle/ty/query/plumbing.rs:71
  46: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1695
  47: rustc_middle::ty::context::tls::set_tlv
             at ./src/librustc_middle/ty/context.rs:1679
  48: rustc_middle::ty::context::tls::enter_context
             at ./src/librustc_middle/ty/context.rs:1695
  49: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}
             at ./src/librustc_middle/ty/query/plumbing.rs:71
  50: rustc_middle::ty::context::tls::with_related_context::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1783
  51: rustc_middle::ty::context::tls::with_context::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1767
  52: rustc_middle::ty::context::tls::with_context_opt
             at ./src/librustc_middle/ty/context.rs:1756
  53: rustc_middle::ty::context::tls::with_context
             at ./src/librustc_middle/ty/context.rs:1767
  54: rustc_middle::ty::context::tls::with_related_context
             at ./src/librustc_middle/ty/context.rs:1780
  55: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query
             at ./src/librustc_middle/ty/query/plumbing.rs:60
  56: rustc_query_system::query::plumbing::force_query_with_job::{{closure}}
             at ./src/librustc_query_system/query/plumbing.rs:582
  57: rustc_query_system::query::plumbing::with_diagnostics
             at ./src/librustc_query_system/query/plumbing.rs:292
  58: rustc_query_system::query::plumbing::force_query_with_job
             at ./src/librustc_query_system/query/plumbing.rs:581
  59: rustc_query_system::query::plumbing::try_execute_query
             at ./src/librustc_query_system/query/plumbing.rs:409
  60: rustc_query_system::query::plumbing::get_query::{{closure}}
             at ./src/librustc_query_system/query/plumbing.rs:626
  61: <rustc_query_system::query::caches::DefaultCache<K,V> as rustc_query_system::query::caches::QueryCache>::lookup
             at ./src/librustc_query_system/query/caches.rs:91
  62: rustc_query_system::query::plumbing::try_get_cached
             at ./src/librustc_query_system/query/plumbing.rs:367
  63: rustc_query_system::query::plumbing::get_query
             at ./src/librustc_query_system/query/plumbing.rs:618
  64: rustc_query_system::query::plumbing::ensure_query
             at ./src/librustc_query_system/query/plumbing.rs:660
  65: rustc_middle::ty::query::TyCtxtEnsure::check_item_well_formed
             at ./src/librustc_middle/ty/query/plumbing.rs:384
  66: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc_hir::itemlikevisit::ParItemLikeVisitor>::visit_item
             at src/librustc_typeck/check/wfcheck.rs:1259
  67: rustc_hir::hir::Crate::par_visit_all_item_likes::{{closure}}::{{closure}}
             at ./src/librustc_hir/hir.rs:687
  68: rustc_data_structures::sync::par_for_each_in::{{closure}}::{{closure}}
             at ./src/librustc_data_structures/sync.rs:211
  69: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at ./src/libstd/panic.rs:318
  70: std::panicking::try::do_call
             at ./src/libstd/panicking.rs:331
  71: std::panicking::try::do_try
             at src/libstd/panicking.rs:298
  72: std::panicking::try
             at ./src/libstd/panicking.rs:274
  73: std::panic::catch_unwind
             at ./src/libstd/panic.rs:394
  74: rustc_data_structures::sync::par_for_each_in::{{closure}}
             at ./src/librustc_data_structures/sync.rs:211
  75: core::iter::traits::iterator::Iterator::for_each::call::{{closure}}
             at ./src/libcore/iter/traits/iterator.rs:655
  76: core::iter::traits::iterator::Iterator::fold::ok::{{closure}}
             at ./src/libcore/iter/traits/iterator.rs:2002
  77: core::iter::traits::iterator::Iterator::try_fold
             at ./src/libcore/iter/traits/iterator.rs:1878
  78: core::iter::traits::iterator::Iterator::fold
             at ./src/libcore/iter/traits/iterator.rs:2005
  79: core::iter::traits::iterator::Iterator::for_each
             at ./src/libcore/iter/traits/iterator.rs:658
  80: rustc_data_structures::sync::par_for_each_in
             at ./src/librustc_data_structures/sync.rs:210
  81: rustc_hir::hir::Crate::par_visit_all_item_likes::{{closure}}
             at ./src/librustc_hir/hir.rs:686
  82: core::ops::function::FnOnce::call_once
             at ./src/libcore/ops/function.rs:232
  83: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at ./src/libstd/panic.rs:318
  84: std::panicking::try::do_call
             at ./src/libstd/panicking.rs:331
  85: std::panicking::try::do_try
             at src/libstd/panicking.rs:298
  86: std::panicking::try
             at ./src/libstd/panicking.rs:274
  87: std::panic::catch_unwind
             at ./src/libstd/panic.rs:394
  88: rustc_hir::hir::Crate::par_visit_all_item_likes
             at ./<::rustc_data_structures::sync::parallel macros>:4
  89: rustc_typeck::check::check_wf_new
             at src/librustc_typeck/check/mod.rs:743
  90: rustc_typeck::check_crate::{{closure}}::{{closure}}
             at src/librustc_typeck/lib.rs:337
  91: rustc_data_structures::profiling::VerboseTimingGuard::run
             at ./src/librustc_data_structures/profiling.rs:569
  92: rustc_session::utils::<impl rustc_session::session::Session>::time
             at ./src/librustc_session/utils.rs:9
  93: rustc_typeck::check_crate::{{closure}}
             at src/librustc_typeck/lib.rs:337
  94: rustc_session::session::Session::track_errors
             at ./src/librustc_session/session.rs:299
  95: rustc_typeck::check_crate
             at src/librustc_typeck/lib.rs:336
  96: rustc_interface::passes::analysis
             at src/librustc_interface/passes.rs:808
  97: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
             at ./src/librustc_middle/ty/query/plumbing.rs:357
  98: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
             at ./src/librustc_query_system/dep_graph/graph.rs:303
  99: rustc_query_system::dep_graph::graph::DepGraph<K>::with_eval_always_task
             at ./src/librustc_query_system/dep_graph/graph.rs:336
 100: rustc_query_system::query::plumbing::force_query_with_job::{{closure}}::{{closure}}
             at ./src/librustc_query_system/query/plumbing.rs:584
 101: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}
             at ./src/librustc_middle/ty/query/plumbing.rs:71
 102: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1695
 103: rustc_middle::ty::context::tls::set_tlv
             at ./src/librustc_middle/ty/context.rs:1679
 104: rustc_middle::ty::context::tls::enter_context
             at ./src/librustc_middle/ty/context.rs:1695
 105: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}
             at ./src/librustc_middle/ty/query/plumbing.rs:71
 106: rustc_middle::ty::context::tls::with_related_context::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1783
 107: rustc_middle::ty::context::tls::with_context::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1767
 108: rustc_middle::ty::context::tls::with_context_opt
             at ./src/librustc_middle/ty/context.rs:1756
 109: rustc_middle::ty::context::tls::with_context
             at ./src/librustc_middle/ty/context.rs:1767
 110: rustc_middle::ty::context::tls::with_related_context
             at ./src/librustc_middle/ty/context.rs:1780
 111: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query
             at ./src/librustc_middle/ty/query/plumbing.rs:60
 112: rustc_query_system::query::plumbing::force_query_with_job::{{closure}}
             at ./src/librustc_query_system/query/plumbing.rs:582
 113: rustc_query_system::query::plumbing::with_diagnostics
             at ./src/librustc_query_system/query/plumbing.rs:292
 114: rustc_query_system::query::plumbing::force_query_with_job
             at ./src/librustc_query_system/query/plumbing.rs:581
 115: rustc_query_system::query::plumbing::try_execute_query
             at ./src/librustc_query_system/query/plumbing.rs:409
 116: rustc_query_system::query::plumbing::get_query::{{closure}}
             at ./src/librustc_query_system/query/plumbing.rs:626
 117: <rustc_query_system::query::caches::DefaultCache<K,V> as rustc_query_system::query::caches::QueryCache>::lookup
             at ./src/librustc_query_system/query/caches.rs:91
 118: rustc_query_system::query::plumbing::try_get_cached
             at ./src/librustc_query_system/query/plumbing.rs:367
 119: rustc_query_system::query::plumbing::get_query
             at ./src/librustc_query_system/query/plumbing.rs:618
 120: rustc_middle::ty::query::TyCtxtAt::analysis
             at ./src/librustc_middle/ty/query/plumbing.rs:462
 121: rustc_middle::ty::query::<impl rustc_middle::ty::context::TyCtxt>::analysis
             at ./src/librustc_middle/ty/query/plumbing.rs:425
 122: rustc_driver::run_compiler::{{closure}}::{{closure}}::{{closure}}
             at src/librustc_driver/lib.rs:386
 123: rustc_middle::ty::context::tls::enter_global::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1718
 124: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at ./src/librustc_middle/ty/context.rs:1695
 125: rustc_middle::ty::context::tls::set_tlv
             at ./src/librustc_middle/ty/context.rs:1679
 126: rustc_middle::ty::context::tls::enter_context
             at ./src/librustc_middle/ty/context.rs:1695
 127: rustc_middle::ty::context::tls::enter_global
             at ./src/librustc_middle/ty/context.rs:1718
 128: rustc_interface::passes::QueryContext::enter
             at ./src/librustc_interface/passes.rs:709
 129: rustc_driver::run_compiler::{{closure}}::{{closure}}
             at src/librustc_driver/lib.rs:386
 130: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
             at ./src/librustc_interface/queries.rs:385
 131: rustc_driver::run_compiler::{{closure}}
             at src/librustc_driver/lib.rs:286
 132: rustc_interface::interface::run_compiler_in_existing_thread_pool
             at ./src/librustc_interface/interface.rs:199
 133: rustc_interface::interface::run_compiler::{{closure}}
             at ./src/librustc_interface/interface.rs:213
 134: rustc_interface::util::spawn_thread_pool::{{closure}}::{{closure}}::{{closure}}
             at ./src/librustc_interface/util.rs:152
 135: scoped_tls::ScopedKey<T>::set
             at /home/dwrensha/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137
 136: rustc_interface::util::spawn_thread_pool::{{closure}}::{{closure}}
             at ./src/librustc_interface/util.rs:148
 137: scoped_tls::ScopedKey<T>::set
             at /home/dwrensha/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137
 138: rustc_ast::attr::with_globals::{{closure}}
             at ./src/librustc_ast/attr/mod.rs:44
 139: scoped_tls::ScopedKey<T>::set
             at /home/dwrensha/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137
 140: rustc_ast::attr::with_globals
             at ./src/librustc_ast/attr/mod.rs:44
 141: rustc_interface::util::spawn_thread_pool::{{closure}}
             at ./src/librustc_interface/util.rs:147
 142: rustc_interface::util::scoped_thread::{{closure}}
             at ./src/librustc_interface/util.rs:122
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.44.0-dev running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_item_well_formed] processing `<T as FooExt>`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
@jonas-schievink jonas-schievink added A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 5, 2020
@jonas-schievink jonas-schievink added A-inference Area: Type inference I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 2, 2020
@matthewjasper matthewjasper self-assigned this May 2, 2020
@estebank
Copy link
Contributor

estebank commented May 2, 2020

Fixed in current stable, beta and nightly:

error[E0637]: `&` without an explicit lifetime name cannot be used here
 --> file55.rs:2:36
  |
2 | pub trait FooExt where for<'b> &'b &mut Self: Foo {}
  |                                    ^ explicit lifetime name needed here

error[E0277]: the trait bound `for<'b> &'b &'static mut T: Foo` is not satisfied
 --> file55.rs:3:9
  |
2 | pub trait FooExt where for<'b> &'b &mut Self: Foo {}
  |                                               --- required by this bound in `FooExt`
3 | impl<T> FooExt for T where for<'a> &'a mut T: Foo {}
  |         ^^^^^^ the trait `for<'b> Foo` is not implemented for `&'b &'static mut T`

error: aborting due to 2 previous errors

The second error should probably not be emitted as I believe it is caused by a placeholder 'static lifetime used during recovery. We should introduce (or use if it is already there) a lifetime equivalent to TyErr.

@estebank estebank added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 2, 2020
@matthewjasper matthewjasper removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 2, 2020
@matthewjasper
Copy link
Contributor

This only happens in builds with debug assertions. It's not fixed in master.

@spastorino
Copy link
Member

Assigning P-low as discussed as part of the Prioritization Working Group process and removing I-prioritize.

@spastorino spastorino added P-low Low priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 4, 2020
@bors bors closed this as completed in 705671e May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inference Area: Type inference A-lifetimes Area: Lifetimes / regions C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants