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

error: internal compiler error: unexpected panic: Failed to get crate data for crate21 #85386

Closed
T0mstone opened this issue May 16, 2021 · 16 comments
Labels
A-metadata Area: Crate metadata C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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

@T0mstone
Copy link

T0mstone commented May 16, 2021

Code

See here.

Meta

rustc --version --verbose:

rustc 1.52.1 (9bc8c42bb 2021-05-09)
binary: rustc
commit-hash: 9bc8c42bb2f19e745a63f3445f1ac248fb015e53
commit-date: 2021-05-09
host: x86_64-unknown-linux-gnu
release: 1.52.1
LLVM version: 12.0.0

This bug also persists in beta and nightly:

rustc 1.53.0-beta.2 (4bac69dd2 2021-05-07)
binary: rustc
commit-hash: 4bac69dd25089dd2f803f24de2225d84449b6220
commit-date: 2021-05-07
host: x86_64-unknown-linux-gnu
release: 1.53.0-beta.2
LLVM version: 12.0.0
rustc 1.54.0-nightly (8cf990c9b 2021-05-15)
binary: rustc
commit-hash: 8cf990c9b5c59f25c806fad9f4466f9d6509bbea
commit-date: 2021-05-15
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1

Error output

thread 'rustc' panicked at 'Failed to get crate data for crate20', compiler/rustc_metadata/src/creader.rs:136:32
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.52.1 (9bc8c42bb 2021-05-09) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --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 `graphite-editor-core`

On different invokations the crate20 has also been crate21

Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:435:5
   2: rustc_metadata::creader::CrateLoader::maybe_resolve_crate
   3: rustc_metadata::creader::CrateLoader::maybe_process_path_extern
   4: rustc_resolve::Resolver::extern_prelude_get
   5: rustc_resolve::macros::<impl rustc_resolve::Resolver>::early_resolve_ident_in_lexical_scope
   6: rustc_resolve::Resolver::resolve_path_with_ribs::{{closure}}
   7: rustc_resolve::Resolver::resolve_path_with_ribs
   8: rustc_resolve::imports::ImportResolver::resolve_imports
   9: rustc_resolve::macros::<impl rustc_expand::base::ResolverExpand for rustc_resolve::Resolver>::resolve_imports
  10: rustc_expand::expand::MacroExpander::fully_expand_fragment
  11: rustc_expand::expand::MacroExpander::expand_crate
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_interface::passes::configure_and_expand_inner
  14: rustc_interface::passes::configure_and_expand::{{closure}}
  15: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
  16: rustc_interface::passes::configure_and_expand
  17: rustc_interface::queries::Queries::expansion
  18: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  19: rustc_span::with_source_map
  20: rustc_interface::interface::create_compiler_and_run
  21: scoped_tls::ScopedKey<T>::set

@T0mstone T0mstone 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 May 16, 2021
@jonas-schievink jonas-schievink added the A-metadata Area: Crate metadata label May 16, 2021
@TrueDoctor
Copy link

This issue only occurs when compiling to wasm32-unknown-unknown. Steps to reproduce:
cd core/editor
cargo build --target wasm32-unknown-unknown

@jonas-schievink jonas-schievink added E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels May 17, 2021
@jonas-schievink
Copy link
Contributor

@rustbot ping cleanup

@rustbot
Copy link
Collaborator

rustbot commented May 17, 2021

@rustbot rustbot added the ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections label May 17, 2021
@TrueDoctor
Copy link

@jonas-schievink I started a bisect today and can confirm the issue existed for at least 3 months, but could not got further back because we use some newer rust features I have to replace, please let me know if I can help with anything (I'll try to work on a "minimal" code sample)

@TrueDoctor
Copy link

I did some initial code reduction that lives in the ice-debugging branch.
I also ran cargo bisect-rustc -v --target wasm32-unknown-unknown --regress ice --start=2018-02-05 --end=2021-05-17 -- build --target wasm32-unknown-unknown
which confirmed that the error existed since at least nightly-2019-12-30. Before then I got the error:

error[E0432]: unresolved import `proc_macro`
  --> /home/dennis/build/Graphite/proc-macro/src/lib.rs:13:5
   |
13 | use proc_macro::TokenStream;
   |     ^^^^^^^^^^ help: a similar path exists: `syn::proc_macro`

error: aborting due to previous error

This is indeed peculiar, reduced the falty code to:
proc-macro/src/lib.rs

use proc_macro::TokenStream;

#[proc_macro_derive(ToDiscriminant)]
pub fn derive_discriminant(_: TokenStream) -> TokenStream {
    TokenStream::new()
}

#[proc_macro_derive(TransitiveChild)]
pub fn derive_transitive_child(_: TokenStream) -> TokenStream {
    TokenStream::new()
}

editor/src/lib.rs

pub use proc_macros::{ToDiscriminant, TransitiveChild};

This causes the error when executing cargo check --target wasm32-unknown-unknown

@jonas-schievink
Copy link
Contributor

That's interesting, so this bug existed since 2019? Something must have changed that made it show up much more often then.

@jonas-schievink jonas-schievink added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 17, 2021
@jonas-schievink
Copy link
Contributor

Not sure how to handle this further so I'll defer to the prioritization folks

@TrueDoctor
Copy link

Things get even weirder: while trying to bisect older versions, I added extern crate proc_macros to the editor/src/lib.rs and this caused the issue to go away.
When I tried the same thing on our main codebase, I got this lovely backtrace:

Backtrace

    Checking graphite-editor-core v0.1.0 (/home/dennis/Projects/rust/Graphite/core/editor)
thread 'rustc' panicked at 'Failed to get crate data for crate20', compiler/rustc_metadata/src/creader.rs:136:32
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.52.1 (9bc8c42bb 2021-05-09) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack
error: internal compiler error: expansion entered force mode without producing any errors
 --> core/editor/src/communication/document_action_handler.rs:7:1
  |
7 | #[impl_message(Message, Document)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_expand/src/expand.rs:450:34

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1013:13
stack backtrace:
   0:     0x7f314d29b990 - std::backtrace_rs::backtrace::libunwind::trace::h63b7a90188ab5fb3
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f314d29b990 - std::backtrace_rs::backtrace::trace_unsynchronized::h80aefbf9b851eca7
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f314d29b990 - std::sys_common::backtrace::_print_fmt::hbef05ae4237a4d72
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f314d29b990 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h28abce2fdb9884c2
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f314d309f1f - core::fmt::write::h3b84512577ca38a8
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/fmt/mod.rs:1092:17
   5:     0x7f314d28fae2 - std::io::Write::write_fmt::h465f8feea02e2aa1
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/io/mod.rs:1572:15
   6:     0x7f314d29f7d5 - std::sys_common::backtrace::_print::h525280ee0d29bdde
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f314d29f7d5 - std::sys_common::backtrace::print::h1f0f5b9f3ef8fb78
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f314d29f7d5 - std::panicking::default_hook::{{closure}}::ha5838f6faa4a5a8f
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:208:50
   9:     0x7f314d29f283 - std::panicking::default_hook::hfb9fe98acb0dcb3b
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:225:9
  10:     0x7f314da705eb - rustc_driver::report_ice::hfd0c5c387cfb7249
  11:     0x7f3142c33413 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hbf80f92e2ef22df5
                               at /home/dennis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1560:9
  12:     0x7f3142cd45f6 - proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}::{{closure}}::h49290f5a3dfb1191
                               at /home/dennis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro/src/bridge/client.rs:320:21
  13:     0x7f314d29ff40 - std::panicking::rust_panic_with_hook::hb89f5f19036e6af8
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:595:17
  14:     0x7f314d29fab7 - std::panicking::begin_panic_handler::{{closure}}::h119e7951427f41da
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:497:13
  15:     0x7f314d29be4c - std::sys_common::backtrace::__rust_end_short_backtrace::hce386c44bf47a128
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys_common/backtrace.rs:141:18
  16:     0x7f314d29fa19 - rust_begin_unwind
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:493:5
  17:     0x7f314d26416b - std::panicking::begin_panic_fmt::h400b8e9dca200408
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:435:5
  18:     0x7f314ffa340e - rustc_errors::HandlerInner::flush_delayed::h263755ef17509b2a
  19:     0x7f314ffa1d7b - <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop::h37a2b959f25c1a7e
  20:     0x7f314f714506 - core::ptr::drop_in_place<rustc_session::parse::ParseSess>::hf3df97dfbfd1ff07
  21:     0x7f314f71713d - <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop::hed6de597fa439e98
  22:     0x7f314f71340d - core::ptr::drop_in_place<rustc_interface::interface::Compiler>::h6861ead4ffd5d1e1
  23:     0x7f314f712f48 - rustc_span::with_source_map::h2cd9a6094ef7af0e
  24:     0x7f314f71904e - rustc_interface::interface::create_compiler_and_run::h5877f5f12804db55
  25:     0x7f314f7138f8 - scoped_tls::ScopedKey<T>::set::hd60de2a62f3fb82b
  26:     0x7f314f7193fb - std::sys_common::backtrace::__rust_begin_short_backtrace::hf09e28c4d01a4892
  27:     0x7f314f730a35 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hff3afb7d3b239db0
  28:     0x7f314d2af72a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc444a77f8dd8d825
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/alloc/src/boxed.rs:1546:9
  29:     0x7f314d2af72a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8b68a0a9a2093dfc
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/alloc/src/boxed.rs:1546:9
  30:     0x7f314d2af72a - std::sys::unix::thread::Thread::new::thread_start::hb95464447f61f48d
                               at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/sys/unix/thread.rs:71:17
  31:     0x7f314d1b4259 - start_thread
  32:     0x7f314d0c95e3 - __GI___clone
  33:                0x0 - <unknown>

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.52.1 (9bc8c42bb 2021-05-09) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
error: could not compile `graphite-editor-core`

Caused by:
  process didn't exit successfully: `rustc --crate-name graphite_editor_core --edition=2018 core/editor/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -C metadata=10a1f6dc65bf6e11 -C extra-filename=-10a1f6dc65bf6e11 --out-dir /home/dennis/Projects/rust/Graphite/target/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -C incremental=/home/dennis/Projects/rust/Graphite/target/wasm32-unknown-unknown/debug/incremental -L dependency=/home/dennis/Projects/rust/Graphite/target/wasm32-unknown-unknown/debug/deps -L dependency=/home/dennis/Projects/rust/Graphite/target/debug/deps --extern bitflags=/home/dennis/Projects/rust/Graphite/target/wasm32-unknown-unknown/debug/deps/libbitflags-32b8b9be07796006.rmeta --extern document_core=/home/dennis/Projects/rust/Graphite/target/wasm32-unknown-unknown/debug/deps/libgraphite_document_core-753b9e7c4d48b2df.rmeta --extern proc_macros=/home/dennis/Projects/rust/Graphite/target/debug/deps/libgraphite_proc_macros-81b09e1ce2e4acb2.so --extern log=/home/dennis/Projects/rust/Graphite/target/wasm32-unknown-unknown/debug/deps/liblog-b4e782aaa47756a7.rmeta --extern serde=/home/dennis/Projects/rust/Graphite/target/wasm32-unknown-unknown/debug/deps/libserde-da223e3e6520aad4.rmeta --extern thiserror=/home/dennis/Projects/rust/Graphite/target/wasm32-unknown-unknown/debug/deps/libthiserror-9cc1f778e48efd39.rmeta` (signal: 4, SIGILL: illegal instruction)

@jonas-schievink
Copy link
Contributor

cc @petrochenkov

@TrueDoctor
Copy link

It seems like I ran into #56935 when adding the explicit extern crate.
Not sure if it is related

@TrueDoctor
Copy link

This issue was indeed fixed by applying the extern crate workaround.
The backtrace generated in here might still be interesting because it caused two ICE's

@apiraino
Copy link
Contributor

apiraino commented May 20, 2021

Nominating to discussion during T-compiler meeting to try to understand if this specific to the target and perhaps summon someone more familiar with it

I think the reduction by @TrueDoctor (thanks!) is great to isolate the issue, so removing the ICE-breaker label

@rustbot label +I-nominated -ICEBreaker-Cleanup-Crew

@rustbot rustbot added I-nominated and removed ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections labels May 20, 2021
@apiraino
Copy link
Contributor

apiraino commented May 20, 2021

issue has been discussed during the compile meeting (Zulip log)

@pnkfelix
Copy link
Member

I discussed this with @alexcrichton . They confirmed that it looks like a duplicate of issue #56935. That is: this is not a wasm-specific bug, but rather a bug with cross-compilation in general.

As alex put it, "looks like the proc macro is loaded twice by accident. er maybe 3 times even..." (and they were very pleased by the MCVE)

@TrueDoctor
Copy link

@pnkfelix Is there anything more I can do? This is my first interaction with rust-lang/rust but it has been quite fun so far.
I believe the second error I encountered:

error: internal compiler error: expansion entered force mode without producing any errors
 --> core/editor/src/communication/document_action_handler.rs:7:1
  |
7 | #[impl_message(Message, Document)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_expand/src/expand.rs:450:34

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1013:13
stack backtrace:

is probably just a side effect of the first one.
I don't know how the policies are but it seems sensible to close this issue and continue the discussion elsewhere

@apiraino
Copy link
Contributor

I'll go and close this issue as duplicate, as the discussion demonstrates (this won't block discussing the issue here or on #56935 or Zulip)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-metadata Area: Crate metadata C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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

6 participants