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

rust failed to build (branch beta 02822334e9b) thread 'rustc' panicked at 'called Result::unwrap() on an Err value: "invalid enum variant tag while decoding StabilityLevel, expected 0..2"', compiler/rustc_metadata/src/rmeta/decoder.rs:266:29 #92812

Closed
culugyx opened this issue Jan 12, 2022 · 3 comments
Labels
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

@culugyx
Copy link

culugyx commented Jan 12, 2022

Code

I'm trying to build rust itself, from the beta branch:

And it failed with: thread 'rustc' panicked at 'called Result::unwrap() on an Err value: "invalid enum variant tag while decoding StabilityLevel, expected 0..2"', compiler/rustc_metadata/src/rmeta/decoder.rs:266:29

Error output

$ export RUST_BACKTRACE=1
$ ./x.py build
Updating only changed submodules
  Submodules updated in 0.01 seconds
Building rustbuild
    Finished dev [unoptimized] target(s) in 0.29s
Building stage0 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.27s
Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage0 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.59s
Copying stage0 rustc from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Assembling stage1 compiler (x86_64-unknown-linux-gnu)
Building stage1 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.20s
Copying stage1 std from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building stage1 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
   Compiling gsgdt v0.1.2
   Compiling tracing-subscriber v0.3.3
   Compiling thorin-dwp v0.1.1
   Compiling rls-span v0.5.3
   Compiling serde_json v1.0.59
   Compiling rustc_data_structures v0.0.0 (.../rust/compiler/rustc_data_structures)
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: "invalid enum variant tag while decoding `StabilityLevel`, expected 0..2"', compiler/rustc_metadata/src/rmeta/decoder.rs:266:29
stack backtrace:
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: "invalid enum variant tag while decoding `StabilityLevel`, expected 0..2"', compiler/rustc_metadata/src/rmeta/decoder.rs:266:29
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: <rustc_metadata::rmeta::decoder::MetadataBlob>::get_root
   3: <rustc_metadata::rmeta::decoder::MetadataBlob>::get_root
   4: <rustc_metadata::locator::CrateLocator>::extract_one
   5: <rustc_metadata::locator::CrateLocator>::extract_lib
   6: <rustc_metadata::locator::CrateLocator>::find_library_crate
   4: <rustc_metadata::locator::CrateLocator>::extract_one
   5: <rustc_metadata::locator::CrateLocator>::extract_lib
   6: <rustc_metadata::locator::CrateLocator>::find_library_crate
   7: <rustc_metadata::locator::CrateLocator>::maybe_load_library_crate
   7: <rustc_metadata::locator::CrateLocator>::maybe_load_library_crate
   8: <rustc_metadata::creader::CrateLoader>::load
   8: <rustc_metadata::creader::CrateLoader>::load
   9: <rustc_metadata::creader::CrateLoader>::maybe_resolve_crate
   9: <rustc_metadata::creader::CrateLoader>::maybe_resolve_crate
  10: <rustc_metadata::creader::CrateLoader>::maybe_resolve_crate
  11: <rustc_metadata::creader::CrateLoader>::resolve_crate
  10: <rustc_metadata::creader::CrateLoader>::maybe_resolve_crate
  11: <rustc_metadata::creader::CrateLoader>::maybe_process_path_extern
  12: <rustc_metadata::creader::CrateLoader>::process_extern_crate
  13: <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor as rustc_ast::visit::Visitor>::visit_item
  12: <rustc_resolve::Resolver>::extern_prelude_get
  13: <rustc_resolve::Resolver>::early_resolve_ident_in_lexical_scope
  14: <rustc_resolve::Resolver>::resolve_path_with_ribs::{closure#1}
  15: <rustc_resolve::Resolver>::resolve_path_with_ribs
  16: <rustc_resolve::imports::ImportResolver>::resolve_imports
  17: <rustc_resolve::Resolver as rustc_expand::base::ResolverExpand>::resolve_imports
  14: <rustc_expand::expand::AstFragment>::visit_with::<rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor>
  18: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
  19: <rustc_expand::expand::MacroExpander>::expand_crate
  15: <rustc_resolve::Resolver as rustc_expand::base::ResolverExpand>::visit_ast_fragment_with_placeholders
  16: <rustc_expand::expand::MacroExpander>::collect_invocations
  17: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
  18: <rustc_expand::expand::MacroExpander>::expand_crate
  19: <rustc_session::session::Session>::time::<core::result::Result<rustc_ast::ast::Crate, rustc_errors::ErrorReported>, rustc_interface::passes::configure_and_expand::{closure#1}>
  20: <rustc_session::session::Session>::time::<core::result::Result<rustc_ast::ast::Crate, rustc_errors::ErrorReported>, rustc_interface::passes::configure_and_expand::{closure#1}>
  21: rustc_interface::passes::configure_and_expand
  20: rustc_interface::passes::configure_and_expand
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: "invalid enum variant tag while decoding `StabilityLevel`, expected 0..2"', compiler/rustc_metadata/src/rmeta/decoder.rs:266:29
  22: <rustc_interface::queries::Queries>::expansion
  21: <rustc_interface::queries::Queries>::expansion
stack backtrace:
  23: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  22: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  23: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  24: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  24: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>
  25: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>
  25: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
  26: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

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

note: compiler flags: -Z macro-backtrace -Z tls-model=initial-exec -Z unstable-options -Z binary-dep-depinfo -Z force-unstable-if-unmarked -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C symbol-mangling-version=v0 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -C prefer-dynamic --crate-type lib

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

query stack during panic:
end of query stack
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-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z macro-backtrace -Z tls-model=initial-exec -Z unstable-options -Z binary-dep-depinfo -Z force-unstable-if-unmarked -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C symbol-mangling-version=v0 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -C prefer-dynamic --crate-type lib

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

query stack during panic:
end of query stack
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: <rustc_metadata::rmeta::decoder::MetadataBlob>::get_root
   4: <rustc_metadata::locator::CrateLocator>::extract_one
   5: <rustc_metadata::locator::CrateLocator>::extract_lib
   6: <rustc_metadata::locator::CrateLocator>::find_library_crate
   7: <rustc_metadata::locator::CrateLocator>::maybe_load_library_crate
   8: <rustc_metadata::creader::CrateLoader>::load
   9: <rustc_metadata::creader::CrateLoader>::maybe_resolve_crate
  10: <rustc_metadata::creader::CrateLoader>::maybe_resolve_crate
  11: <rustc_metadata::creader::CrateLoader>::maybe_process_path_extern
  12: <rustc_resolve::Resolver>::extern_prelude_get
  13: <rustc_resolve::Resolver>::early_resolve_ident_in_lexical_scope
  14: <rustc_resolve::Resolver>::resolve_path_with_ribs::{closure#1}
  15: <rustc_resolve::Resolver>::resolve_path_with_ribs
  16: <rustc_resolve::imports::ImportResolver>::resolve_imports
  17: <rustc_resolve::Resolver as rustc_expand::base::ResolverExpand>::resolve_imports
  18: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
  19: <rustc_expand::expand::MacroExpander>::expand_crate
  20: <rustc_session::session::Session>::time::<core::result::Result<rustc_ast::ast::Crate, rustc_errors::ErrorReported>, rustc_interface::passes::configure_and_expand::{closure#1}>
  21: rustc_interface::passes::configure_and_expand
  22: <rustc_interface::queries::Queries>::expansion
  23: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  24: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  25: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>
  26: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
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-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z macro-backtrace -Z tls-model=initial-exec -Z unstable-options -Z binary-dep-depinfo -Z force-unstable-if-unmarked -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -C symbol-mangling-version=v0 -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -C prefer-dynamic --crate-type lib

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

query stack during panic:
end of query stack
error: could not compile `rustc_data_structures`
warning: build failed, waiting for other jobs to finish...
error: build failed
Build completed unsuccessfully in 0:00:05
Backtrace

<backtrace>

@culugyx culugyx 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 Jan 12, 2022
@ehuss
Copy link
Contributor

ehuss commented Jan 12, 2022

This is a somewhat normal problem when building from source. I suspect you may have a build directory left over from a previous build? Normally rustc has a version check to ignore rlib and rmeta files that are from a different version of the compiler. However, the default mode when building from source is to not include the full git hash in that version (so that doing local development isn't too painful). If you build across different checkouts where the data structures have changed, that will cause it to fail to decode those files. Setting the channel in config.toml to beta or stable can help work around this. (See also the ignore-git option in config.toml.)

@culugyx
Copy link
Author

culugyx commented Jan 15, 2022

Thank you! Yes, I have a left over build directory. Cleaning it fixed this problem.

@ehuss
Copy link
Contributor

ehuss commented Jan 15, 2022

Sounds good! I'm going to close in favor of #76720 which is the general issue for this. It's an unfortunate part of working on rustc.

@ehuss ehuss closed this as completed Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

2 participants