rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.03k stars 12.79k forks source link

Minor: Compiler panic based on Cargo.toml "version" value #93779

Open rvthak opened 2 years ago

rvthak commented 2 years ago

Minimal reproduction

The bug appears while following this tutorial: https://docs.elrond.com/developers/tutorials/crowdfunding-p1/

  1. Install Elrond IDE extension on vscode (https://marketplace.visualstudio.com/items?itemName=Elrond.vscode-elrond-ide)

  2. On terminal: erdpy contract new crowdfunding --template adder code crowdfunding

  3. Open file Cargo.toml

  4. Set "version" to "0.0.1"

  5. Compile the code using erdpy contract build

  6. Compiler panics (It makes no sence)

  7. If you change "version" to something else (like 0.1.1) the problem self resolves.

  8. Setting the value back to "0.0.1" causes the compiler to panic again

Code

It doesn't seem to be affected at all by the rust code itself

Meta

rustc --version --verbose:

<version>
rustc 1.58.1 (db9d1b20b 2022-01-20)
binary: rustc
commit-hash: db9d1b20bba1968c1ec1fc49616d4742c1725b4b
commit-date: 2022-01-20
host: x86_64-unknown-linux-gnu
release: 1.58.1
LLVM version: 13.0.0

Error output

<output>
INFO:projects.core:build_project.directory: /home/pigeon/Downloads/contract/crowdfunding
INFO:projects.core:build_project.debug: False
INFO:myprocess:run_process: ['rustc', '--version'], in folder: None
INFO:myprocess:Successful run. Output:
rustc 1.59.0-nightly (78fd0f633 2021-12-29)

Compiling crowdfunding v0.0.1 (/home/pigeon/Downloads/contract/crowdfunding)
Compiling crowdfunding-meta v0.0.0 (/home/pigeon/Downloads/contract/crowdfunding/meta)
thread 'rustc' panicked at 'no entry found for key', compiler/rustc_metadata/src/rmeta/decoder.rs:1631:13
note: run with `RUST_BACKTRACE=1` environment variable to display a 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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.59.0-nightly (78fd0f633 2021-12-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `crowdfunding-meta`
CRITICAL:cli:Build error: error code = 101, see output.

``` Im a newbie to both rust and vscode and all the methods of setting RUST_BACKTRACE didn't seem to work for me. How do you properly set its value? ```

bjorn3 commented 2 years ago

This is probably related to incremental compilation. I think thid specific issue has already been fixed on nightly (and maybe beta) It is probably unrelated to version. I think it perturbed the input to rustc just enough to cause this issue.

msrd0 commented 2 years ago

I just hit an ICE that looks similar to the one reported here:

thread 'rustc' panicked at 'no entry found for key', compiler/rustc_metadata/src/rmeta/decoder.rs:1617:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/1.59.0/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/1.59.0/library/core/src/panicking.rs:116:14
   2: core::panicking::panic_display
             at /rustc/1.59.0/library/core/src/panicking.rs:72:5
   3: core::panicking::panic_str
             at /rustc/1.59.0/library/core/src/panicking.rs:56:5
   4: core::option::expect_failed
             at /rustc/1.59.0/library/core/src/option.rs:1817:5
   5: <rustc_metadata::creader::CStore as rustc_session::cstore::CrateStore>::expn_hash_to_expn_id
   6: <rustc_span::hygiene::ExpnId as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   7: <rustc_span::hygiene::SyntaxContextData as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   8: <rustc_query_impl::on_disk_cache::CacheDecoder as rustc_middle::ty::codec::TyDecoder>::with_position::<<rustc_span::hygiene::SyntaxContext as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}::{closure#0}, core::result::Result<rustc_span::hygiene::SyntaxContextData, alloc::string::String>>
   9: <rustc_span::hygiene::SyntaxContext as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  10: <rustc_span::span_encoding::Span as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  11: <rustc_middle::ty::VariantDef as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  12: <rustc_query_impl::on_disk_cache::CacheDecoder as rustc_serialize::serialize::Decoder>::read_seq::<alloc::vec::Vec<rustc_middle::ty::VariantDef>, <alloc::vec::Vec<rustc_middle::ty::VariantDef> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>
  13: <rustc_middle::ty::adt::AdtDef as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  14: <rustc_middle::ty::sty::TyKind as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  15: <&rustc_middle::ty::TyS as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  16: <rustc_middle::ty::subst::GenericArg as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  17: <core::result::Result<rustc_middle::ty::subst::GenericArg, alloc::string::String> as rustc_middle::ty::context::InternIteratorElement<rustc_middle::ty::subst::GenericArg, &rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg>>>::intern_with::<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>, <rustc_middle::ty::context::TyCtxt>::mk_substs<core::iter::adapters::map::Map<core::ops::range::Range<usize>, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>::{closure#0}>
  18: <rustc_middle::traits::ImplSource<()> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  19: <core::result::Result<rustc_middle::traits::ImplSource<()>, rustc_errors::ErrorReported> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  20: <rustc_query_impl::on_disk_cache::OnDiskCache>::try_load_query_result::<core::result::Result<rustc_middle::traits::ImplSource<()>, rustc_errors::ErrorReported>>
  21: <<rustc_query_impl::queries::codegen_fulfill_obligation as rustc_query_system::query::config::QueryDescription<rustc_query_impl::plumbing::QueryCtxt>>::TRY_LOAD_FROM_DISK::{closure#0} as core::ops::function::FnOnce<(rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::dep_graph::serialized::SerializedDepNodeIndex)>>::call_once
  22: rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl::plumbing::QueryCtxt, (rustc_middle::ty::ParamEnv, rustc_middle::ty::sty::Binder<rustc_middle::ty::sty::TraitRef>), core::result::Result<rustc_middle::traits::ImplSource<()>, rustc_errors::ErrorReported>>
  23: rustc_data_structures::stack::ensure_sufficient_stack::<core::option::Option<(core::result::Result<rustc_middle::traits::ImplSource<()>, rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex)>, rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (rustc_middle::ty::ParamEnv, rustc_middle::ty::sty::Binder<rustc_middle::ty::sty::TraitRef>), core::result::Result<rustc_middle::traits::ImplSource<()>, rustc_errors::ErrorReported>>::{closure#2}>
  24: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::codegen_fulfill_obligation, rustc_query_impl::plumbing::QueryCtxt>
  25: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::codegen_fulfill_obligation
  26: rustc_ty_utils::instance::inner_resolve_instance
  27: rustc_ty_utils::instance::resolve_instance
  28: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory<rustc_query_impl::plumbing::QueryCtxt, rustc_middle::ty::ParamEnvAnd<(rustc_span::def_id::DefId, &rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg>)>, core::result::Result<core::option::Option<rustc_middle::ty::instance::Instance>, rustc_errors::ErrorReported>>::{closure#0}, core::result::Result<core::option::Option<rustc_middle::ty::instance::Instance>, rustc_errors::ErrorReported>>
  29: rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl::plumbing::QueryCtxt, rustc_middle::ty::ParamEnvAnd<(rustc_span::def_id::DefId, &rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg>)>, core::result::Result<core::option::Option<rustc_middle::ty::instance::Instance>, rustc_errors::ErrorReported>>
  30: rustc_data_structures::stack::ensure_sufficient_stack::<core::option::Option<(core::result::Result<core::option::Option<rustc_middle::ty::instance::Instance>, rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex)>, rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, rustc_middle::ty::ParamEnvAnd<(rustc_span::def_id::DefId, &rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg>)>, core::result::Result<core::option::Option<rustc_middle::ty::instance::Instance>, rustc_errors::ErrorReported>>::{closure#2}>
  31: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::resolve_instance, rustc_query_impl::plumbing::QueryCtxt>
  32: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::resolve_instance
  33: <rustc_middle::ty::instance::Instance>::resolve_opt_const_arg
  34: <rustc_middle::ty::instance::Instance>::resolve
  35: <rustc_monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_terminator
  36: rustc_monomorphize::collector::collect_neighbours
  37: rustc_monomorphize::collector::collect_items_rec
  38: rustc_monomorphize::collector::collect_items_rec
  39: rustc_monomorphize::collector::collect_items_rec
  40: rustc_monomorphize::collector::collect_items_rec
  41: rustc_monomorphize::collector::collect_items_rec
  42: rustc_monomorphize::collector::collect_items_rec
  43: rustc_monomorphize::collector::collect_items_rec
  44: rustc_monomorphize::collector::collect_items_rec
  45: rustc_monomorphize::collector::collect_items_rec
  46: rustc_monomorphize::collector::collect_items_rec
  47: rustc_monomorphize::collector::collect_items_rec
  48: rustc_monomorphize::collector::collect_items_rec
  49: rustc_monomorphize::collector::collect_items_rec
  50: rustc_monomorphize::collector::collect_items_rec
  51: rustc_monomorphize::collector::collect_items_rec
  52: rustc_monomorphize::collector::collect_items_rec
  53: rustc_monomorphize::collector::collect_items_rec
  54: rustc_monomorphize::collector::collect_items_rec
  55: rustc_monomorphize::collector::collect_items_rec
  56: rustc_monomorphize::collector::collect_items_rec
  57: rustc_monomorphize::collector::collect_items_rec
  58: rustc_monomorphize::collector::collect_items_rec
  59: rustc_monomorphize::collector::collect_items_rec
  60: rustc_monomorphize::collector::collect_items_rec
  61: rustc_monomorphize::collector::collect_items_rec
  62: rustc_monomorphize::collector::collect_items_rec
  63: rustc_monomorphize::collector::collect_items_rec
  64: rustc_monomorphize::collector::collect_items_rec
  65: rustc_monomorphize::collector::collect_items_rec
  66: rustc_monomorphize::collector::collect_items_rec
  67: rustc_monomorphize::collector::collect_items_rec
  68: rustc_monomorphize::collector::collect_items_rec
  69: rustc_monomorphize::collector::collect_items_rec
  70: rustc_monomorphize::collector::collect_items_rec
  71: rustc_monomorphize::collector::collect_items_rec
  72: rustc_monomorphize::collector::collect_items_rec
  73: rustc_monomorphize::collector::collect_items_rec
  74: rustc_monomorphize::collector::collect_items_rec
  75: rustc_monomorphize::collector::collect_items_rec
  76: rustc_monomorphize::collector::collect_items_rec
  77: rustc_monomorphize::collector::collect_items_rec
  78: rustc_monomorphize::collector::collect_items_rec
  79: rustc_monomorphize::collector::collect_items_rec
  80: rustc_monomorphize::collector::collect_items_rec
  81: rustc_monomorphize::collector::collect_items_rec
  82: rustc_monomorphize::collector::collect_items_rec
  83: rustc_monomorphize::collector::collect_items_rec
  84: rustc_monomorphize::collector::collect_items_rec
  85: rustc_monomorphize::collector::collect_items_rec
  86: rustc_monomorphize::collector::collect_items_rec
  87: rustc_monomorphize::collector::collect_items_rec
  88: rustc_monomorphize::collector::collect_items_rec
  89: rustc_monomorphize::collector::collect_items_rec
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.59.0 (Arch Linux rust 1:1.59.0-1) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C linker=/usr/bin/clang -C incremental -C link-arg=-fuse-ld=lld --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [codegen_fulfill_obligation] checking if `serde::de::DeserializeSeed` fulfills its obligations
#1 [resolve_instance] resolving instance `<core::marker::PhantomData<my_crate::_::<impl serde::de::Deserialize<'de> for my_crate::SomeStruct>::deserialize::__Field> as serde::de::DeserializeSeed>::deserialize::<&mut serde_json::de::Deserializer<serde_json::read::SliceRead>>`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

Removing the target folder and recompiling the entire project fixes the problem.

bjorn3 commented 2 years ago

@msrd0 Did you force enable incremental compilation? As noted in https://blog.rust-lang.org/2022/02/24/Rust-1.59.0.html#incremental-compilation-off-by-default incremental compilation has been disabled in rustc 1.59 due to this kind of bugs. It should be fixed in rustc 1.60.

msrd0 commented 2 years ago

Yes, looks like I never removed the RUSTC_FORCE_INCREMENTAL variable from my bashrc since it was re-enabled by default after 1.52.1.

istankovic commented 1 year ago

@rvthak is this still relevant?