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

Huge compilation time for small snippet using async and explicit lifetimes #72051

Closed
bjorn3 opened this issue May 9, 2020 · 5 comments · Fixed by #72087
Closed

Huge compilation time for small snippet using async and explicit lifetimes #72051

bjorn3 opened this issue May 9, 2020 · 5 comments · Fixed by #72087
Labels
A-lifetimes Area: lifetime related C-bug Category: This is a bug. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bjorn3
Copy link
Member

bjorn3 commented May 9, 2020

pub struct DbClient(());

impl DbClient {
    pub async fn query<'a>(&self, sql: &str, params: &'a [&'a (dyn std::any::Any + Sync + 'a)]) {}
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
/playground/tools/entrypoint.sh: line 11:    11 Killed                  timeout --signal=KILL ${timeout} "$@"

Backtrace:

* thread #2, name = 'rustc', stop reason = signal SIGSTOP
  * frame #0: 0x00007fab5853c3be librustc_driver-1772d117996df5b4.so`rustc_infer::infer::free_regions::FreeRegionMap::check_relation::h025e2ec4bfa478fc (.llvm.6299244459994015461) + 94
    frame #1: 0x00007fab585cf03e librustc_driver-1772d117996df5b4.so`rustc_infer::infer::lexical_region_resolve::LexicalResolver::sub_concrete_regions::hfd9d949aaa7dca94 + 254
    frame #2: 0x00007fab585ccb23 librustc_driver-1772d117996df5b4.so`rustc_infer::infer::lexical_region_resolve::LexicalResolver::infer_variable_values::hc4b0d81cb2ebd244 + 3171
    frame #3: 0x00007fab585cbc69 librustc_driver-1772d117996df5b4.so`rustc_infer::infer::lexical_region_resolve::resolve::h762bae7b729632b2 + 377
    frame #4: 0x00007fab585ab49f librustc_driver-1772d117996df5b4.so`rustc_infer::infer::InferCtxt::resolve_regions_and_report_errors::h24818ca63f255f79 + 1119
    frame #5: 0x00007fab56cd788e librustc_driver-1772d117996df5b4.so`rustc_typeck::check::regionck::_$LT$impl$u20$rustc_typeck..check..FnCtxt$GT$::regionck_fn::h4dce4596df885e8a + 542
    frame #6: 0x00007fab56ea8319 librustc_driver-1772d117996df5b4.so`rustc_middle::ty::context::GlobalCtxt::enter_local::he4a8a7cc4c50587b + 4777
    frame #7: 0x00007fab56cdc632 librustc_driver-1772d117996df5b4.so`rustc_typeck::check::typeck_tables_of::h2029253d05dd9bad (.llvm.4268970034425336421) + 626
    frame #8: 0x00007fab5740ac2e librustc_driver-1772d117996df5b4.so`rustc_middle::ty::query::_$LT$impl$u20$rustc_query_system..query..config..QueryAccessors$LT$rustc_middle..ty..context..TyCtxt$GT$$u20$for$u20$rustc_middle..ty..query..queries..typeck_tables_of$GT$::compute::hcd4f27e634c2155a + 94
    frame #9: 0x00007fab573a9161 librustc_driver-1772d117996df5b4.so`rustc_middle::dep_graph::_$LT$impl$u20$rustc_query_system..dep_graph..DepKind$u20$for$u20$rustc_middle..dep_graph..dep_node..DepKind$GT$::with_deps::h126d84c928aecbbe + 177
    frame #10: 0x00007fab57357778 librustc_driver-1772d117996df5b4.so`rustc_query_system::dep_graph::graph::DepGraph$LT$K$GT$::with_task_impl::hd221bc61c2a8a1f8 (.llvm.12373976628643104377) + 344
    frame #11: 0x00007fab573c7d5f librustc_driver-1772d117996df5b4.so`rustc_data_structures::stack::ensure_sufficient_stack::h2deab4d5ca782e0a + 639
    frame #12: 0x00007fab573f2a6c librustc_driver-1772d117996df5b4.so`rustc_query_system::query::plumbing::get_query_impl::h7ca3f2a2ef8469b2 + 3388
    frame #13: 0x00007fab5741193c librustc_driver-1772d117996df5b4.so`rustc_mir_build::hair::cx::Cx::new::h850876704a8dce73 + 476
    frame #14: 0x00007fab573c1d95 librustc_driver-1772d117996df5b4.so`rustc_infer::infer::InferCtxtBuilder::enter::ha83c4cd1ad779694 + 1093
    frame #15: 0x00007fab5736926a librustc_driver-1772d117996df5b4.so`rustc_mir_build::build::mir_built::h03e5221c7337eb43 + 570
    frame #16: 0x00007fab5796e982 librustc_driver-1772d117996df5b4.so`rustc_middle::ty::query::_$LT$impl$u20$rustc_query_system..query..config..QueryAccessors$LT$rustc_middle..ty..context..TyCtxt$GT$$u20$for$u20$rustc_middle..ty..query..queries..mir_built$GT$::compute::h25788372c05cb73c + 98
    frame #17: 0x00007fab5765269e librustc_driver-1772d117996df5b4.so`rustc_middle::dep_graph::_$LT$impl$u20$rustc_query_system..dep_graph..DepKind$u20$for$u20$rustc_middle..dep_graph..dep_node..DepKind$GT$::with_deps::h5317bd3bec1e3042 + 190
    frame #18: 0x00007fab577ba299 librustc_driver-1772d117996df5b4.so`rustc_query_system::dep_graph::graph::DepGraph$LT$K$GT$::with_task_impl::hdbe770784e4263ca (.llvm.14764133895945772940) + 393
    frame #19: 0x00007fab5778476d librustc_driver-1772d117996df5b4.so`rustc_query_system::query::plumbing::get_query_impl::hceff08f493f50398 + 5613
    frame #20: 0x00007fab579d045d librustc_driver-1772d117996df5b4.so`rustc_mir::transform::check_unsafety::unsafety_check_result::h1790fad567b5075a (.llvm.2873478104022101212) + 93
    frame #21: 0x00007fab578cc552 librustc_driver-1772d117996df5b4.so`rustc_middle::ty::query::_$LT$impl$u20$rustc_query_system..query..config..QueryAccessors$LT$rustc_middle..ty..context..TyCtxt$GT$$u20$for$u20$rustc_middle..ty..query..queries..unsafety_check_result$GT$::compute::h31e4fe0b86967eb6 + 98
    frame #22: 0x00007fab57656b4e librustc_driver-1772d117996df5b4.so`rustc_middle::dep_graph::_$LT$impl$u20$rustc_query_system..dep_graph..DepKind$u20$for$u20$rustc_middle..dep_graph..dep_node..DepKind$GT$::with_deps::hbffce002855d77d6 + 190
    frame #23: 0x00007fab577af787 librustc_driver-1772d117996df5b4.so`rustc_query_system::dep_graph::graph::DepGraph$LT$K$GT$::with_task_impl::h41fa1796f8ba84c3 (.llvm.14764133895945772940) + 375
    frame #24: 0x00007fab57752a9c librustc_driver-1772d117996df5b4.so`rustc_query_system::query::plumbing::get_query_impl::h5d6b3dbc5bb6b690 + 5532
    frame #25: 0x00007fab57920e92 librustc_driver-1772d117996df5b4.so`rustc_mir::transform::mir_const::ha11335d1234306ae (.llvm.15598305148491436955) + 114
    frame #26: 0x00007fab578cbb4e librustc_driver-1772d117996df5b4.so`rustc_middle::ty::query::_$LT$impl$u20$rustc_query_system..query..config..QueryAccessors$LT$rustc_middle..ty..context..TyCtxt$GT$$u20$for$u20$rustc_middle..ty..query..queries..mir_const$GT$::compute::h66bca047eccd2ffd + 110
    frame #27: 0x00007fab57657868 librustc_driver-1772d117996df5b4.so`rustc_middle::dep_graph::_$LT$impl$u20$rustc_query_system..dep_graph..DepKind$u20$for$u20$rustc_middle..dep_graph..dep_node..DepKind$GT$::with_deps::he78c1ea4e9918210 + 200
    frame #28: 0x00007fab577b9ca0 librustc_driver-1772d117996df5b4.so`rustc_query_system::dep_graph::graph::DepGraph$LT$K$GT$::with_task_impl::hd13d9a5b0fe080d9 (.llvm.14764133895945772940) + 416
    frame #29: 0x00007fab57749217 librustc_driver-1772d117996df5b4.so`rustc_query_system::query::plumbing::get_query_impl::h44483db05f1b9dc4 + 5799
    frame #30: 0x00007fab57921171 librustc_driver-1772d117996df5b4.so`rustc_mir::transform::mir_validated::hce8ac31de4c7f661 (.llvm.15598305148491436955) + 177
    frame #31: 0x00007fab5796ece2 librustc_driver-1772d117996df5b4.so`rustc_middle::ty::query::_$LT$impl$u20$rustc_query_system..query..config..QueryAccessors$LT$rustc_middle..ty..context..TyCtxt$GT$$u20$for$u20$rustc_middle..ty..query..queries..mir_validated$GT$::compute::ha02338f486e7a64e + 98
    frame #32: 0x00007fab5765644e librustc_driver-1772d117996df5b4.so`rustc_middle::dep_graph::_$LT$impl$u20$rustc_query_system..dep_graph..DepKind$u20$for$u20$rustc_middle..dep_graph..dep_node..DepKind$GT$::with_deps::hb0ceab957788b62f + 190
    frame #33: 0x00007fab577b84d9 librustc_driver-1772d117996df5b4.so`rustc_query_system::dep_graph::graph::DepGraph$LT$K$GT$::with_task_impl::hb9a0e7283334c5e0 (.llvm.14764133895945772940) + 393
    frame #34: 0x00007fab5772271d librustc_driver-1772d117996df5b4.so`rustc_query_system::query::plumbing::get_query_impl::h00f8c8cd0012688a + 5613
    frame #35: 0x00007fab579c19b1 librustc_driver-1772d117996df5b4.so`rustc_mir::borrow_check::mir_borrowck::hd104706380baec83 (.llvm.2873478104022101212) + 97
    frame #36: 0x00007fab56d07872 librustc_driver-1772d117996df5b4.so`rustc_middle::ty::query::_$LT$impl$u20$rustc_query_system..query..config..QueryAccessors$LT$rustc_middle..ty..context..TyCtxt$GT$$u20$for$u20$rustc_middle..ty..query..queries..mir_borrowck$GT$::compute::hf2226f7559873d8f + 98
    frame #37: 0x00007fab56d88b5e librustc_driver-1772d117996df5b4.so`rustc_middle::dep_graph::_$LT$impl$u20$rustc_query_system..dep_graph..DepKind$u20$for$u20$rustc_middle..dep_graph..dep_node..DepKind$GT$::with_deps::h3b1f76081851e93e + 190
    frame #38: 0x00007fab56ec2d14 librustc_driver-1772d117996df5b4.so`rustc_query_system::dep_graph::graph::DepGraph$LT$K$GT$::with_task_impl::hc1dc89d85b9e6f06 (.llvm.8645209709966053388) + 468
    frame #39: 0x00007fab56e249e7 librustc_driver-1772d117996df5b4.so`rustc_query_system::query::plumbing::get_query_impl::h4465e3e4b3cd8724 + 6391
    frame #40: 0x00007fab56d1b4dd librustc_driver-1772d117996df5b4.so`rustc_typeck::collect::type_of::type_of::h79851aee43991f39 + 4669
    frame #41: 0x00007fab58c95f21 librustc_driver-1772d117996df5b4.so`rustc_middle::dep_graph::_$LT$impl$u20$rustc_query_system..dep_graph..DepKind$u20$for$u20$rustc_middle..dep_graph..dep_node..DepKind$GT$::with_deps::hc0d17fd8beb7fca7 + 193
    frame #42: 0x00007fab587705cf librustc_driver-1772d117996df5b4.so`rustc_query_system::dep_graph::graph::DepGraph$LT$K$GT$::with_task_impl::h028cb48d94eeafa6 (.llvm.1950428790096281317) + 463
    frame #43: 0x00007fab58bcc583 librustc_driver-1772d117996df5b4.so`rustc_data_structures::stack::ensure_sufficient_stack::hfc6fb82cb8ae45d7 + 243
    frame #44: 0x00007fab58890df8 librustc_driver-1772d117996df5b4.so`rustc_query_system::query::plumbing::get_query_impl::hc4ef44a8c8d7056b + 3880
    frame #45: 0x00007fab58c18249 librustc_driver-1772d117996df5b4.so`rustc_middle::ty::util::_$LT$impl$u20$rustc_middle..ty..context..TyCtxt$GT$::try_expand_impl_trait_type::OpaqueTypeExpander::expand_opaque_ty::h2ae507b3f50991ad + 617
    frame #46: 0x00007fab589a6ec1 librustc_driver-1772d117996df5b4.so`rustc_middle::ty::util::_$LT$impl$u20$rustc_middle..ty..context..TyCtxt$GT$::try_expand_impl_trait_type::h6ad39effcbac2a23 + 177
    frame #47: 0x00007fab56ce0362 librustc_driver-1772d117996df5b4.so`rustc_typeck::check::check_item_type::h696fd6947b840e11 (.llvm.4268970034425336421) + 4482
    frame #48: 0x00007fab56d85506 librustc_driver-1772d117996df5b4.so`rustc_middle::hir::map::Map::visit_item_likes_in_module::h39e82ce130f61e9f + 326
    frame #49: 0x00007fab56cdbd5d librustc_driver-1772d117996df5b4.so`rustc_typeck::check::check_mod_item_types::h01d46ce1a1226ad0 (.llvm.4268970034425336421) + 29
    frame #50: 0x00007fab56eeb1c2 librustc_driver-1772d117996df5b4.so`rustc_middle::ty::query::_$LT$impl$u20$rustc_query_system..query..config..QueryAccessors$LT$rustc_middle..ty..context..TyCtxt$GT$$u20$for$u20$rustc_middle..ty..query..queries..check_mod_item_types$GT$::compute::hce03d68086597979 + 98
    frame #51: 0x00007fab56d862af librustc_driver-1772d117996df5b4.so`rustc_middle::dep_graph::_$LT$impl$u20$rustc_query_system..dep_graph..DepKind$u20$for$u20$rustc_middle..dep_graph..dep_node..DepKind$GT$::with_deps::h02878f5719beb591 + 191
    frame #52: 0x00007fab56ec629a librustc_driver-1772d117996df5b4.so`rustc_query_system::dep_graph::graph::DepGraph$LT$K$GT$::with_task_impl::he09c42094142f85c (.llvm.8645209709966053388) + 362
    frame #53: 0x00007fab56e31550 librustc_driver-1772d117996df5b4.so`rustc_query_system::query::plumbing::get_query_impl::h5d95f922513763da + 4512
    frame #54: 0x00007fab56e6b777 librustc_driver-1772d117996df5b4.so`rustc_query_system::query::plumbing::ensure_query_impl::hc109069fe65c51cb + 167
    frame #55: 0x00007fab56f1e6a1 librustc_driver-1772d117996df5b4.so`rustc_typeck::check_crate::hf52f6324b18d4db4 + 4097
    frame #56: 0x00007fab566da2f4 librustc_driver-1772d117996df5b4.so`rustc_interface::passes::analysis::h6d809b9127d1df5d + 116
    frame #57: 0x00007fab56321a3b librustc_driver-1772d117996df5b4.so`rustc_middle::ty::query::_$LT$impl$u20$rustc_query_system..query..config..QueryAccessors$LT$rustc_middle..ty..context..TyCtxt$GT$$u20$for$u20$rustc_middle..ty..query..queries..analysis$GT$::compute::he31be01f92f630cb + 91
    frame #58: 0x00007fab562ec878 librustc_driver-1772d117996df5b4.so`rustc_middle::dep_graph::_$LT$impl$u20$rustc_query_system..dep_graph..DepKind$u20$for$u20$rustc_middle..dep_graph..dep_node..DepKind$GT$::with_deps::hd785bbdf8b3e5c6f + 184
    frame #59: 0x00007fab5646d215 librustc_driver-1772d117996df5b4.so`rustc_query_system::dep_graph::graph::DepGraph$LT$K$GT$::with_task_impl::h8b90ad06db3eaeca (.llvm.5859842509920574174) + 341
    frame #60: 0x00007fab562f0578 librustc_driver-1772d117996df5b4.so`rustc_data_structures::stack::ensure_sufficient_stack::h7cb8d36df1565b9a + 264
    frame #61: 0x00007fab56474adb librustc_driver-1772d117996df5b4.so`rustc_query_system::query::plumbing::get_query_impl::h3655d22c01adc2a8 + 2715
    frame #62: 0x00007fab56321c47 librustc_driver-1772d117996df5b4.so`rustc_middle::ty::context::tls::enter_global::h172f152fc22b01e3 + 199
    frame #63: 0x00007fab562ee369 librustc_driver-1772d117996df5b4.so`rustc_interface::interface::run_compiler_in_existing_thread_pool::h24d68d75bb23a364 + 3849

@rustbot modify labels: +I-hang +T-compiler +C-bug +A-lifetimes

@rustbot rustbot added A-lifetimes Area: lifetime related C-bug Category: This is a bug. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 9, 2020
@jonas-schievink jonas-schievink added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 9, 2020
@lcnr
Copy link
Contributor

lcnr commented May 9, 2020

somewhat minimized:

pub async fn query<'a>(_: &(), _: &(), params: (&(dyn std::any::Any + 'a),) ) {}
fn main() {}

To replicate this I needed:

  • async
  • two other arguments by ref
    • at least one arg must not be bound to 'a, async fn query<'a>(_: &'a (), _: &'a (), params: (&(dyn std::any::Any + 'a),) ) {} compiles quickly
  • the problematic argument must be contain an indirection: &&(dyn std::any::Any + 'a) compiles fine.
    • Vec<&(dyn std::any::Any + 'a)> and [&(dyn std::any::Any + 'a); 0] also freeze.
  • and a trait object containing at least one non marker trait explicitly bound to 'a.
    • &(dyn Send + 'a) and &(dyn std::any::Any) are both ok

@dtolnay dtolnay added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label May 9, 2020
@dtolnay
Copy link
Member

dtolnay commented May 9, 2020

@lcnr's repro is a regression in 1.43. It compiles immediately with 1.39 through 1.42.

@dtolnay dtolnay added the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label May 9, 2020
@wesleywiser wesleywiser added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 9, 2020
@bjorn3
Copy link
Member Author

bjorn3 commented May 10, 2020

I am currently bisecting this using

//- main.rs
pub async fn query<'a>(_: &(), _: &(), params: (&(dyn std::any::Any + 'a),) ) {}
fn main() {}
#- test.sh
timeout 1 rustc main.rs --edition 2018
$ cargo bisect-rustc --script ./test.sh --access github

@bjorn3
Copy link
Member Author

bjorn3 commented May 10, 2020

regression in 8498c5f

@rustbot modify labels: -E-needs-bisection

@rustbot rustbot removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label May 10, 2020
@dtolnay
Copy link
Member

dtolnay commented May 10, 2020

FYI @nikomatsakis, @Centril, @matthewjasper who had context on #65232.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue May 13, 2020
…matsakis

Fix hang in lexical_region_resolve

Regionck was stuck in a loop where a region value was changing between two equal regions.

Closes rust-lang#72051
@bors bors closed this as completed in 2e65f7b May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: lifetime related C-bug Category: This is a bug. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

6 participants