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

Potential race condition with rust-analyzer #113062

Closed
qredek opened this issue Jun 26, 2023 · 2 comments
Closed

Potential race condition with rust-analyzer #113062

qredek opened this issue Jun 26, 2023 · 2 comments
Labels
A-incr-comp Area: Incremental compilation 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.

Comments

@qredek
Copy link

qredek commented Jun 26, 2023

Not sure if this is even a bug, but it seems that there was a race condition with rust-analyzer that was running in the background.

Rebuilding the project via

cargo clean
cargo build --workspace

succeeds.

It occurred when

  • there was TUI editor with rust-analyzer instance attached,
  • I suspended the editor was suspended via CTRL-Z, then
  • I tried to build the workspace using cargo build --workspace (in a different terminal),
  • cargo got stuck on _waiting for file lock on build directory`,
  • I resumed the editor by running fg, and at this point
  • cargo resumed, but
  • rustc panicked with the error below.

Code

I don't think this bug was caused by a particular code sample. M

Meta

rustc --version --verbose:

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: aarch64-apple-darwin
release: 1.70.0
LLVM version: 16.0.2

Error output

thread 'rustc' panicked at 'Found unstable fingerprints for mir_built(f446436312aca093-f1818964d56a366): Steal { value: RwLock(RefCell { value: Some(Body { basic_blocks: BasicBlocks { basic_blocks: [BasicBlockData { statements: [StorageLive(_2), _2 = <Everything as Contains<RuntimeCall>>::contains, FakeRead(ForLet(None), _2), StorageLive(_3), StorageLive(_4), StorageLive(_5), StorageLive(_6), _6 = _2], terminator: Some(Terminator { source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#355), scope: scope[1] }, kind: _5 = std::boxed::Box::<for<'a> fn(&'a RuntimeCall) -> bool {<Everything as Contains<RuntimeCall>>::contains}>::new(move _6) -> [return: bb1, unwind: bb9] }), is_cleanup: false }, BasicBlockData { statements: [_4 = move _5 as std::boxed::Box<dyn for<'a> std::ops::Fn(&'a RuntimeCall) -> bool> (Pointer(Unsize))], terminator: Some(Terminator { source_info: SourceInfo { span: /Users/jakub.zalewski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tt-call-1.0.9/src/lib.rs:652:9: 652:10 (#355), scope: scope[1] }, kind: drop(_5) -> [return: bb2, unwind: bb8] }), is_cleanup: false }, BasicBlockData { statements: [StorageDead(_6), StorageDead(_5)], terminator: Some(Terminator { source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#355), scope: scope[1] }, kind: _3 = Rc::<std::boxed::Box<dyn for<'a> Fn(&'a RuntimeCall) -> bool>>::new(move _4) -> [return: bb3, unwind: bb8] }), is_cleanup: false }, BasicBlockData { statements: [StorageDead(_4)], terminator: Some(Terminator { source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#1387), scope: scope[1] }, kind: drop(((*_1).1: std::rc::Rc<std::boxed::Box<dyn for<'a> std::ops::Fn(&'a RuntimeCall) -> bool>>)) -> [return: bb4, unwind: bb5] }), is_cleanup: false }, BasicBlockData { statements: [((*_1).1: std::rc::Rc<std::boxed::Box<dyn for<'a> std::ops::Fn(&'a RuntimeCall) -> bool>>) = move _3], terminator: Some(Terminator { source_info: SourceInfo { span: /Users/jakub.zalewski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tt-call-1.0.9/src/lib.rs:652:9: 652:10 (#355), scope: scope[1] }, kind: drop(_3) -> [return: bb6, unwind: bb9] }), is_cleanup: false }, BasicBlockData { statements: [((*_1).1: std::rc::Rc<std::boxed::Box<dyn for<'a> std::ops::Fn(&'a RuntimeCall) -> bool>>) = move _3], terminator: Some(Terminator { source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#1387), scope: scope[1] }, kind: goto -> bb7 }), is_cleanup: true }, BasicBlockData { statements: [StorageDead(_3), _0 = const (), StorageDead(_2)], terminator: Some(Terminator { source_info: SourceInfo { span: /Users/jakub.zalewski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tt-call-1.0.9/src/lib.rs:652:10: 652:10 (#355), scope: scope[0] }, kind: return }), is_cleanup: false }, BasicBlockData { statements: [], terminator: Some(Terminator { source_info: SourceInfo { span: /Users/jakub.zalewski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tt-call-1.0.9/src/lib.rs:652:9: 652:10 (#355), scope: scope[1] }, kind: drop(_3) -> [return: bb9, unwind terminate] }), is_cleanup: true }, BasicBlockData { statements: [], terminator: Some(Terminator { source_info: SourceInfo { span: /Users/jakub.zalewski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tt-call-1.0.9/src/lib.rs:652:9: 652:10 (#355), scope: scope[1] }, kind: drop(_4) -> [return: bb9, unwind terminate] }), is_cleanup: true }, BasicBlockData { statements: [], terminator: Some(Terminator { source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#355), scope: scope[0] }, kind: resume }), is_cleanup: true }], cache: Cache { predecessors: OnceCell(Uninit), switch_sources: OnceCell(Uninit), is_cyclic: OnceCell(Uninit), postorder: OnceCell(Uninit) } }, phase: Built, pass_count: 0, source: MirSource { instance: Item(WithOptConstParam { did: DefId(0:379 ~ node_template_runtime[b247]::{impl#45}::reset_filter), const_param_did: None }), promoted: None }, source_scopes: [SourceScopeData { span: runtime/src/lib.rs:341:1: 652:10 (#355), parent_scope: None, inlined: None, inlined_parent_scope: None, local_data: Set(SourceScopeLocalData { lint_root: HirId(DefId(0:379 ~ node_template_runtime[b247]::{impl#45}::reset_filter).0), safety: Safe }) }, SourceScopeData { span: runtime/src/lib.rs:341:1: 652:10 (#355), parent_scope: Some(scope[0]), inlined: None, inlined_parent_scope: None, local_data: Set(SourceScopeLocalData { lint_root: HirId(DefId(0:379 ~ node_template_runtime[b247]::{impl#45}::reset_filter).0), safety: Safe }) }], generator: None, local_decls: [LocalDecl { mutability: Mut, local_info: Set(Boring), internal: false, ty: (), user_ty: None, source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 341:1 (#355), scope: scope[0] } }, LocalDecl { mutability: Not, local_info: Set(User(ImplicitSelf(MutRef))), internal: false, ty: &mut RuntimeOrigin, user_ty: None, source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#355), scope: scope[0] } }, LocalDecl { mutability: Not, local_info: Set(User(Var(VarBindingForm { binding_mode: BindByValue(Not), opt_ty_info: None, opt_match_place: Some((None, runtime/src/lib.rs:341:1: 652:10 (#355))), pat_span: runtime/src/lib.rs:341:1: 652:10 (#355) }))), internal: false, ty: for<'a> fn(&'a RuntimeCall) -> bool {<sp_api_hidden_includes_construct_runtime::hidden_include::traits::Everything as sp_api_hidden_includes_construct_runtime::hidden_include::traits::Contains<RuntimeCall>>::contains}, user_ty: None, source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#355), scope: scope[0] } }, LocalDecl { mutability: Mut, local_info: Set(Boring), internal: false, ty: std::rc::Rc<std::boxed::Box<dyn for<'a> std::ops::Fn(&'a RuntimeCall) -> bool>>, user_ty: None, source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#355), scope: scope[0] } }, LocalDecl { mutability: Mut, local_info: Set(Boring), internal: false, ty: std::boxed::Box<dyn for<'a> std::ops::Fn(&'a RuntimeCall) -> bool>, user_ty: None, source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#355), scope: scope[0] } }, LocalDecl { mutability: Mut, local_info: Set(Boring), internal: false, ty: std::boxed::Box<for<'a> fn(&'a RuntimeCall) -> bool {<sp_api_hidden_includes_construct_runtime::hidden_include::traits::Everything as sp_api_hidden_includes_construct_runtime::hidden_include::traits::Contains<RuntimeCall>>::contains}>, user_ty: None, source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#355), scope: scope[0] } }, LocalDecl { mutability: Mut, local_info: Set(Boring), internal: false, ty: for<'a> fn(&'a RuntimeCall) -> bool {<sp_api_hidden_includes_construct_runtime::hidden_include::traits::Everything as sp_api_hidden_includes_construct_runtime::hidden_include::traits::Contains<RuntimeCall>>::contains}, user_ty: None, source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#355), scope: scope[0] } }], user_type_annotations: [CanonicalUserTypeAnnotation { user_ty: Canonical { value: TypeOf(DefId(294:4383 ~ frame_support[4aa6]::traits::members::Contains::contains), UserSubsts { substs: [<Runtime as frame_system::Config>::BaseCallFilter, <Runtime as frame_system::Config>::RuntimeCall], user_self_ty: None }), max_universe: U0, variables: [] }, span: runtime/src/lib.rs:341:1: 652:10 (#355), inferred_ty: for<'a> fn(&'a RuntimeCall) -> bool {<sp_api_hidden_includes_construct_runtime::hidden_include::traits::Everything as sp_api_hidden_includes_construct_runtime::hidden_include::traits::Contains<RuntimeCall>>::contains} }, CanonicalUserTypeAnnotation { user_ty: Canonical { value: TypeOf(DefId(5:4776 ~ alloc[c023]::rc::{impl#7}::new), UserSubsts { substs: [^0], user_self_ty: Some(UserSelfTy { impl_def_id: DefId(5:4774 ~ alloc[c023]::rc::{impl#7}), self_ty: std::rc::Rc<^1> }) }), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }, CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: runtime/src/lib.rs:341:1: 652:10 (#355), inferred_ty: fn(std::boxed::Box<dyn for<'a> std::ops::Fn(&'a RuntimeCall) -> bool>) -> std::rc::Rc<std::boxed::Box<dyn for<'a> std::ops::Fn(&'a RuntimeCall) -> bool>> {std::rc::Rc::<std::boxed::Box<dyn for<'a> std::ops::Fn(&'a RuntimeCall) -> bool>>::new} }, CanonicalUserTypeAnnotation { user_ty: Canonical { value: TypeOf(DefId(5:285 ~ alloc[c023]::boxed::{impl#0}::new), UserSubsts { substs: [^0], user_self_ty: Some(UserSelfTy { impl_def_id: DefId(5:283 ~ alloc[c023]::boxed::{impl#0}), self_ty: std::boxed::Box<^1, ^2> }) }), max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }, CanonicalVarInfo { kind: Ty(General(U0)) }, CanonicalVarInfo { kind: Ty(General(U0)) }] }, span: runtime/src/lib.rs:341:1: 652:10 (#355), inferred_ty: fn(for<'a> fn(&'a RuntimeCall) -> bool {<sp_api_hidden_includes_construct_runtime::hidden_include::traits::Everything as sp_api_hidden_includes_construct_runtime::hidden_include::traits::Contains<RuntimeCall>>::contains}) -> std::boxed::Box<for<'a> fn(&'a RuntimeCall) -> bool {<sp_api_hidden_includes_construct_runtime::hidden_include::traits::Everything as sp_api_hidden_includes_construct_runtime::hidden_include::traits::Contains<RuntimeCall>>::contains}> {std::boxed::Box::<for<'a> fn(&'a RuntimeCall) -> bool {<sp_api_hidden_includes_construct_runtime::hidden_include::traits::Everything as sp_api_hidden_includes_construct_runtime::hidden_include::traits::Contains<RuntimeCall>>::contains}>::new} }], arg_count: 1, spread_arg: None, var_debug_info: [VarDebugInfo { name: "self", source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#355), scope: scope[0] }, value: _1, argument_index: Some(1) }, VarDebugInfo { name: "filter", source_info: SourceInfo { span: runtime/src/lib.rs:341:1: 652:10 (#355), scope: scope[1] }, value: _2, argument_index: None }], span: runtime/src/lib.rs:341:1: 652:10 (#355), required_consts: [], is_polymorphic: false, injection_phase: None, tainted_by_errors: None }) }) }', /rustc/90c541806f23a127002de5b4038be731ba1458ca/compiler/rustc_query_system/src/query/plumbing.rs:715:9
Backtrace


stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: rustc_query_system::query::plumbing::incremental_verify_ich_failed::<rustc_middle::ty::context::TyCtxt>
   3: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::queries::mir_built, rustc_query_impl::plumbing::QueryCtxt>::{closure#1}, core::option::Option<(rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>>::{closure#0}, core::option::Option<(rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>>
   4: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_built, rustc_query_impl::plumbing::QueryCtxt>
   5: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_built
   6: rustc_mir_transform::mir_const
   7: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::queries::mir_const, rustc_query_impl::plumbing::QueryCtxt>::{closure#1}, core::option::Option<(rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>>::{closure#0}, core::option::Option<(rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>>
   8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_const, rustc_query_impl::plumbing::QueryCtxt>
   9: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_const
  10: rustc_mir_transform::mir_promoted
  11: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::queries::mir_promoted, rustc_query_impl::plumbing::QueryCtxt>::{closure#1}, core::option::Option<(rustc_middle::query::erase::Erased<[u8; 16]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>>::{closure#0}, core::option::Option<(rustc_middle::query::erase::Erased<[u8; 16]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>>
  12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_promoted, rustc_query_impl::plumbing::QueryCtxt>
  13: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_promoted
  14: rustc_borrowck::mir_borrowck
  15: <rustc_borrowck::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
  16: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>::{closure#2}, (rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>
  17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
  18: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  19: <core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::par_for_each_in<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::analysis::{closure#2}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once
  20: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_interface::passes::analysis::{closure#2}::{closure#0}>::{closure#0}>
  21: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#2}>
  22: rustc_interface::passes::analysis
  23: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<rustc_query_system::query::plumbing::execute_job_incr<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>::{closure#2}, (rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle::query::erase::Erased<[u8; 1]>, rustc_query_system::dep_graph::graph::DepNodeIndex)>
  24: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  25: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  26: <std::thread::local::LocalKey<core::cell::Cell<*const ()>>>::with::<rustc_middle::ty::context::tls::enter_context<<rustc_middle::ty::context::GlobalCtxt>::enter<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
  27: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}>
  28: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  29: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@qredek qredek added 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 Jun 26, 2023
@lqd
Copy link
Member

lqd commented Jun 26, 2023

This should be fixed on beta and nightly already, would you be able to confirm that the issue doesn't appear there? Thanks a bunch in advance.

@jyn514 jyn514 added the A-incr-comp Area: Incremental compilation label Jun 30, 2023
@qredek
Copy link
Author

qredek commented Jul 25, 2023

Thanks! After switching to nightly, I couldn't replicate the issue so far, so I am closing this at the moment.

@qredek qredek closed this as completed Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation 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.
Projects
None yet
Development

No branches or pull requests

3 participants