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

Crash on "Internal error, cycle detected:" #3883

Closed
bkchr opened this issue Apr 7, 2020 · 6 comments · Fixed by #4951
Closed

Crash on "Internal error, cycle detected:" #3883

bkchr opened this issue Apr 7, 2020 · 6 comments · Fixed by #4951

Comments

@bkchr
Copy link
Contributor

bkchr commented Apr 7, 2020

Rust analyzer crashes on rust-analyzer analysis-stats . with:

thread 'main' panicked at 'Internal error, cycle detected:

__SalsaDatabaseKey { kind: DefDatabaseStorage(crate_def_map_query(CrateId(221))) }
', <::std::macros::panic macros>:5:6
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: rust_begin_unwind
   7: std::panicking::begin_panic_fmt
   8: <T as ra_hir_def::db::DefDatabase>::crate_def_map_query
   9: <T as ra_hir_def::db::DefDatabase>::crate_def_map
  10: ra_hir_def::nameres::collector::collect_defs
  11: ra_hir_def::nameres::CrateDefMap::crate_def_map_query
  12: salsa::runtime::Runtime<DB>::execute_query_implementation
  13: salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade
  14: salsa::derived::slot::Slot<DB,Q,MP>::read
  15: <salsa::derived::DerivedStorage<DB,Q,MP> as salsa::plumbing::QueryStorageOps<DB,Q>>::try_fetch
  16: <T as ra_hir_def::db::DefDatabase>::crate_def_map_query
  17: <T as ra_hir_def::db::DefDatabase>::crate_def_map
  18: ra_hir_def::nameres::collector::collect_defs
  19: ra_hir_def::nameres::CrateDefMap::crate_def_map_query
  20: salsa::runtime::Runtime<DB>::execute_query_implementation
  21: salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade
  22: salsa::derived::slot::Slot<DB,Q,MP>::read
  23: <salsa::derived::DerivedStorage<DB,Q,MP> as salsa::plumbing::QueryStorageOps<DB,Q>>::try_fetch
  24: <T as ra_hir_def::db::DefDatabase>::crate_def_map_query
  25: <T as ra_hir_def::db::DefDatabase>::crate_def_map
  26: ra_hir_def::nameres::collector::collect_defs
  27: ra_hir_def::nameres::CrateDefMap::crate_def_map_query
  28: salsa::runtime::Runtime<DB>::execute_query_implementation
  29: salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade
  30: salsa::derived::slot::Slot<DB,Q,MP>::read
  31: <salsa::derived::DerivedStorage<DB,Q,MP> as salsa::plumbing::QueryStorageOps<DB,Q>>::try_fetch
  32: <T as ra_hir_def::db::DefDatabase>::crate_def_map_query
  33: <T as ra_hir_def::db::DefDatabase>::crate_def_map
  34: ra_hir_def::nameres::collector::collect_defs
  35: ra_hir_def::nameres::CrateDefMap::crate_def_map_query
  36: salsa::runtime::Runtime<DB>::execute_query_implementation
  37: salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade
  38: salsa::derived::slot::Slot<DB,Q,MP>::read
  39: <salsa::derived::DerivedStorage<DB,Q,MP> as salsa::plumbing::QueryStorageOps<DB,Q>>::try_fetch
  40: <T as ra_hir_def::db::DefDatabase>::crate_def_map_query
  41: <T as ra_hir_def::db::DefDatabase>::crate_def_map
  42: ra_hir_def::nameres::collector::collect_defs
  43: ra_hir_def::nameres::CrateDefMap::crate_def_map_query
  44: salsa::runtime::Runtime<DB>::execute_query_implementation
  45: salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade
  46: salsa::derived::slot::Slot<DB,Q,MP>::read
  47: <salsa::derived::DerivedStorage<DB,Q,MP> as salsa::plumbing::QueryStorageOps<DB,Q>>::try_fetch
  48: <T as ra_hir_def::db::DefDatabase>::crate_def_map_query
  49: <T as ra_hir_def::db::DefDatabase>::crate_def_map
  50: ra_hir::code_model::Crate::root_module
  51: rust_analyzer::cli::analysis_stats::analysis_stats
  52: rust_analyzer::main
  53: std::rt::lang_start::{{closure}}
  54: std::panicking::try::do_call
  55: __rust_maybe_catch_panic
  56: std::rt::lang_start_internal
  57: main
  58: __libc_start_main
  59: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Repository: https://github.com/paritytech/substrate

@bkchr
Copy link
Contributor Author

bkchr commented May 13, 2020

@matklad any idea how can I help on this? I tried to look into the code, but got lost really fast. (I know that we have cyclic dependencies via dev-dependencies, however I would expect that rust-analyzer like cargo is able to resolve this anyway)

@bkchr
Copy link
Contributor Author

bkchr commented Jun 9, 2020

@flodiebold any idea maybe?

flodiebold added a commit to flodiebold/rust-analyzer that referenced this issue Jun 19, 2020
@flodiebold
Copy link
Member

@bkchr the npos-elections crate has a direct dependency on itself. Is that intentional?

@bkchr
Copy link
Contributor Author

bkchr commented Jun 19, 2020

Ty for fixing this! ❤️

And not, it should not depend on itself: paritytech/substrate#6444

@flodiebold
Copy link
Member

If that actually works and has an effect though, we might need to handle it differently...

@bkchr
Copy link
Contributor Author

bkchr commented Jun 19, 2020

I think the main problem is that we have other cyclic dependencies as well. But the other ones don't depend on themself directly. You just end up with a reference to your own crate because you import some different crate as dev dependency.

[ERROR ra_project_model] cyclic dependency node-testing -> node-executor
[ERROR ra_project_model] cyclic dependency frame-system -> frame-support
[ERROR ra_project_model] cyclic dependency substrate-test-runtime-client -> sc-block-builder
[ERROR ra_project_model] cyclic dependency sc-service -> sc-block-builder
[ERROR ra_project_model] cyclic dependency sc-service -> sc-chain-spec
[ERROR ra_project_model] cyclic dependency sc-service -> sc-finality-grandpa
[ERROR ra_project_model] cyclic dependency sc-service -> sc-informant
[ERROR ra_project_model] cyclic dependency sc-service -> sc-network
[ERROR ra_project_model] cyclic dependency sc-service -> sc-offchain
[ERROR ra_project_model] cyclic dependency sc-service -> sc-rpc
[ERROR ra_project_model] cyclic dependency sc-service -> sc-transaction-pool
[ERROR ra_project_model] cyclic dependency sc-service -> substrate-test-runtime-client
[ERROR ra_project_model] cyclic dependency sp-runtime-interface -> sp-core
[ERROR ra_project_model] cyclic dependency sp-runtime-interface -> sp-runtime-interface-test-wasm
[ERROR ra_project_model] cyclic dependency sp-runtime-interface -> sp-state-machine
[ERROR ra_project_model] cyclic dependency pallet-balances -> pallet-transaction-payment
[ERROR ra_project_model] cyclic dependency sp-runtime -> sp-state-machine
[ERROR ra_project_model] cyclic dependency sc-client-db -> substrate-test-runtime-client
[ERROR ra_project_model] cyclic dependency sp-io -> sp-core
[ERROR ra_project_model] cyclic dependency sp-io -> sp-runtime-interface
[ERROR ra_project_model] cyclic dependency sp-io -> sp-state-machine
[ERROR ra_project_model] cyclic dependency sp-io -> sp-trie
[ERROR ra_project_model] cyclic dependency substrate-test-runtime -> frame-executive
[ERROR ra_project_model] cyclic dependency substrate-test-runtime -> frame-support
[ERROR ra_project_model] cyclic dependency substrate-test-runtime -> frame-system
[ERROR ra_project_model] cyclic dependency substrate-test-runtime -> pallet-babe
[ERROR ra_project_model] cyclic dependency substrate-test-runtime -> pallet-timestamp
[ERROR ra_project_model] cyclic dependency substrate-test-runtime -> sc-block-builder
[ERROR ra_project_model] cyclic dependency substrate-test-runtime -> sc-executor
[ERROR ra_project_model] cyclic dependency substrate-test-runtime -> sc-service
[ERROR ra_project_model] cyclic dependency substrate-test-runtime -> substrate-test-runtime-client

bors bot added a commit that referenced this issue Jun 19, 2020
4951: Don't panic on crates depending on themselves r=matklad a=flodiebold

Fixes #3883.

Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
@bors bors bot closed this as completed in 584bdde Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants