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

Docker Preview M1 rustc "error: internal compiler error: unexpected panic" #80346

Closed
triscuitcircuit opened this issue Dec 24, 2020 · 17 comments
Closed
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

@triscuitcircuit
Copy link

Code

Github code I was looking at
note: I switched "CONTAINER_RUNTIME" to docker

Meta

rustc --version --verbose:

Docker M1 Preview rustc

rustc 1.48.0 (7eac88abb 2020-11-16) running on x86_64-unknown-linux-gnu"

Host rustc

rustc 1.50.0-nightly (d32c320d7 2020-12-10)
binary: rustc
commit-hash: d32c320d7eee56706486fef6be778495303afe9e
commit-date: 2020-12-10
host: aarch64-apple-darwin
release: 1.50.0-nightly

Error output

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
   Compiling pkg-config v0.3.19
   Compiling unicode-bidi v0.3.4
   Compiling http v0.2.2
   Compiling proc-macro2 v1.0.24
   Compiling proc-macro-hack v0.5.19
   Compiling unicode-normalization v0.1.16
   Compiling lexical-core v0.7.4
   Compiling stdweb v0.4.20
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_mir/src/transform/simplify.rs:544:27
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.48.0 (7eac88abb 2020-11-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debug-assertions=off --crate-type lib

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

error: could not compile `unicode-normalization`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
thread 'rustc' panicked at 'invalid terminator state', compiler/rustc_middle/src/mir/mod.rs:1200:34
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.48.0 (7eac88abb 2020-11-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=3 -C embed-bitcode=no --crate-type lib

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

qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Backtrace

<backtrace>

@triscuitcircuit triscuitcircuit 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 Dec 24, 2020
@jonas-schievink
Copy link
Contributor

Please check if this still happens on the newest nightly

@triscuitcircuit
Copy link
Author

yes, it seems to be an issue with 1.50 nightly with Docker preview on an M1 as well

heres the output:

docker.io/triscuitcircuit/build-rust-nightly:latest
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
   Compiling autocfg v1.0.1
   Compiling pkg-config v0.3.19
   Compiling gimli v0.23.0
   Compiling rustc-demangle v0.1.18
   Compiling object v0.22.0
   Compiling proc-macro-nested v0.1.6
   Compiling serde_json v1.0.60
   Compiling semver v0.9.0
   Compiling byteorder v1.3.4
   Compiling form_urlencoded v1.0.0
   Compiling http v0.2.2
   Compiling failure_derive v0.1.8
   Compiling stdweb-internal-runtime v0.1.5
   Compiling yew v0.17.4
   Compiling heck v0.3.2
   Compiling proc-macro2 v1.0.24
thread 'rustc' panicked at 'invalid terminator state', compiler/rustc_middle/src/mir/mod.rs:1221:34
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.50.0-nightly (0edce6f4b 2020-12-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=3 -C embed-bitcode=no --crate-type lib

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

query stack during panic:
#0 [mir_const] processing MIR for `header::name::parse_hdr`
#1 [mir_promoted] processing `header::name::parse_hdr`
end of query stack
error: could not compile `http`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
qemu: uncaught target signal 11 (Segmentation fault) - core dumped`

@jonas-schievink
Copy link
Contributor

This does not look like a bug in rustc

@triscuitcircuit
Copy link
Author

ah, i mean I only reported it since it says "note: the compiler unexpectedly panicked. this is a bug." but if its not a bug ill close the issue

@camelid
Copy link
Member

camelid commented Dec 25, 2020

@jonas-schievink Why do you say that this doesn't look like a rustc bug?

@jonas-schievink
Copy link
Contributor

Because it would happen on all architectures. This looks more like a qemu or rosetta bug.

@triscuitcircuit
Copy link
Author

defintly not a Rosetta 2 bug since I'm not using that to run Docker or any of the code, but it could be a Qemu bug. I cant tell if its a Rustc, Docker preview bug or Qemu bug at this point however.

@Iron-E
Copy link

Iron-E commented Dec 29, 2020

I'm running into the same issue right now while trying to compile my WIP clinvoice. The crate in question is clinvoice_config, which seems to be failing with the same error message above:

The Log
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_middle/src/ty/query/mod.rs:235:5
stack backtrace:
   0:     0x7f4559e1a6a7 - std::backtrace_rs::backtrace::libunwind::trace::h746c3e9529d524bc
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f4559e1a6a7 - std::backtrace_rs::backtrace::trace_unsynchronized::h86340908ff889faa
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f4559e1a6a7 - std::sys_common::backtrace::_print_fmt::h43f85f9b18230404
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f4559e1a6a7 - ::fmt::hc132ae1a5b5aa7cd
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f4559e8e51c - core::fmt::write::hdf023a0036d2a25f
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/core/src/fmt/mod.rs:1078:17
   5:     0x7f4559e0c692 - std::io::Write::write_fmt::h8580846154bcb66a
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/io/mod.rs:1519:15
   6:     0x7f4559e1e3a5 - std::sys_common::backtrace::_print::h7ee55fed88d107a3
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f4559e1e3a5 - std::sys_common::backtrace::print::h54a7d3e52a524177
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f4559e1e3a5 - std::panicking::default_hook::{{closure}}::h60921e857bf55a40
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/panicking.rs:208:50
   9:     0x7f4559e1defa - std::panicking::default_hook::hf0f9afb1017317fc
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/panicking.rs:225:9
  10:     0x7f455a6d5a68 - rustc_driver::report_ice::hff78d76a39ffbb86
  11:     0x7f4559e1eca6 - std::panicking::rust_panic_with_hook::h8d66bf42b407aaea
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/panicking.rs:595:17
  12:     0x7f4559e1e797 - std::panicking::begin_panic_handler::{{closure}}::hde71edcd925d0c5e
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/panicking.rs:495:13
  13:     0x7f4559e1ab6c - std::sys_common::backtrace::__rust_end_short_backtrace::h8a3c7d6cea578919
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7f4559e1e729 - rust_begin_unwind
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/panicking.rs:493:5
  15:     0x7f4559e8a931 - core::panicking::panic_fmt::h20225113c4a2f8fd
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/core/src/panicking.rs:92:14
  16:     0x7f4559e8a87d - core::panicking::panic::h35b77276aa4b0c12
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/core/src/panicking.rs:50:5
  17:     0x7f455d0b5835 - rustc_middle::ty::query::try_load_from_on_disk_cache::hfa4775df5c5e0180
  18:     0x7f455c3903ca - rustc_query_system::dep_graph::graph::DepGraph::exec_cache_promotions::h8caa69177622351e
  19:     0x7f455c3a8c21 - rustc_middle::dep_graph::::with_deps::hab5675af7737b3e6
  20:     0x7f455c34c3bb - rustc_incremental::persist::save::save_in::h7f4f43356280dc0a
  21:     0x7f455c3471d1 - rustc_data_structures::sync::join::h0120008f852881ce
  22:     0x7f455c3a7cc2 - rustc_middle::dep_graph::::with_deps::h2893ce60eec57bb6
  23:     0x7f455c34b8ef - rustc_incremental::persist::save::save_dep_graph::hffd3fb2ecc639a78
  24:     0x7f455c226daa - rustc_codegen_ssa::base::finalize_tcx::h68106e2729498b3e
  25:     0x7f455ab44457 - ::codegen_crate::h067fffb3870bc5b0
  26:     0x7f455a8f3b2e - rustc_session::utils::::time::had158f21ec5bf4d1
  27:     0x7f455a93682c - rustc_interface::passes::QueryContext::enter::h40067ad7feabcbd0
  28:     0x7f455a98ec93 - rustc_interface::queries::Queries::ongoing_codegen::h4fc36fc05972247d
  29:     0x7f455a67e6e2 - rustc_interface::queries::::enter::hd899306a06575d0c
  30:     0x7f455a7117f7 - rustc_span::with_source_map::ha4e07ff263d0dc1d
  31:     0x7f455a67f88b - rustc_interface::interface::create_compiler_and_run::h1d6d732867d1f489
  32:     0x7f455a72bd60 - scoped_tls::ScopedKey::set::h39c0aa543118d3f3
  33:     0x7f455a732546 - std::sys_common::backtrace::__rust_begin_short_backtrace::h1e5aa72fb9cd6d86
  34:     0x7f455a68727a - core::ops::function::FnOnce::call_once{{vtable.shim}}::hc793837e985b77ce
  35:     0x7f4559e2e65a -  as core::ops::function::FnOnce>::call_once::hea1090dbdcecbf5a
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/alloc/src/boxed.rs:1328:9
  36:     0x7f4559e2e65a -  as core::ops::function::FnOnce>::call_once::h8d5723d3912bd325
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/alloc/src/boxed.rs:1328:9
  37:     0x7f4559e2e65a - std::sys::unix::thread::Thread::new::thread_start::hc17a425ca2995724
                               at /rustc/3d6705aa5abffe94c83bf09af8c3ba3c599845fc/library/std/src/sys/unix/thread.rs:71:17
  38:     0x7f4559d393e9 - start_thread
  39:     0x7f4559c54293 - __GI___clone
  40:                0x0 - 

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.50.0-nightly (3d6705aa5 2020-12-07) running on x86_64-unknown-linux-gnu

Edit: it's gone on the latest nightly

@triscuitcircuit
Copy link
Author

I'm running into the same issue right now while trying to compile my WIP clinvoice. The crate in question is clinvoice_config, which seems to be failing with the same error message above:
The Log

Edit: it's gone on the latest nightly

Strange, even with the latest nightly it still segfaults at the httpcrate for me.

@philipahlberg
Copy link

I'm running into the same issue right now while trying to compile my WIP clinvoice. The crate in question is clinvoice_config, which seems to be failing with the same error message above:
The Log
Edit: it's gone on the latest nightly

Strange, even with the latest nightly it still segfaults at the httpcrate for me.

I'm experiencing the same problem (rustc in Docker on M1):

Logs Compiling http v0.2.1 thread 'rustc' panicked at 'invalid terminator state', compiler/rustc_middle/src/mir/mod.rs:1204:34 stack backtrace: 0: rust_begin_unwind at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:495:5 1: core::panicking::panic_fmt at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/panicking.rs:92:14 2: core::option::expect_failed at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/option.rs:1260:5 3: rustc_middle::mir::BasicBlockData::terminator_mut 4: rustc_mir::transform::simplify::remove_dead_blocks 5: rustc_mir::transform::simplify::simplify_cfg 6: rustc_mir::transform::run_passes 7: rustc_mir::transform::mir_const 8: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::mir_const>::compute 9: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 10: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}}::{{closure}} 11: rustc_query_system::query::plumbing::get_query_impl 12: rustc_mir::transform::mir_promoted 13: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::mir_promoted>::compute 14: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 15: rustc_middle::ty::query::plumbing::::start_query::{{closure}}::{{closure}}::{{closure}} 16: rustc_query_system::query::plumbing::get_query_impl 17: rustc_mir::borrow_check::mir_borrowck 18: core::ops::function::FnOnce::call_once 19: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::mir_borrowck>::compute 20: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 21: rustc_data_structures::stack::ensure_sufficient_stack 22: rustc_query_system::query::plumbing::get_query_impl 23: rustc_query_system::query::plumbing::ensure_query_impl 24: rustc_session::utils::::time 25: rustc_interface::passes::analysis 26: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::analysis>::compute 27: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 28: rustc_data_structures::stack::ensure_sufficient_stack 29: rustc_query_system::query::plumbing::get_query_impl 30: rustc_interface::passes::QueryContext::enter 31: rustc_interface::queries::::enter 32: rustc_span::with_source_map 33: rustc_interface::interface::create_compiler_and_run 34: rustc_span::with_session_globals 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.49.0 (e1884a8 2020-12-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C link-arg=-fuse-ld=lld --crate-type lib

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

query stack during panic:
#0 [mir_const] processing MIR for header::name::parse_hdr
#1 [mir_promoted] processing header::name::parse_hdr
#2 [mir_borrowck] borrow-checking header::name::parse_hdr
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile http

I'll try to setup a repo that reproduces the error (source repo isn't public, unfortunately).

@camelid
Copy link
Member

camelid commented Feb 3, 2021

If it happens while compiling a public library (which it looks like it does), I think you in theory can just set up an empty repo depending on that crate and it should reproduce.

@philipahlberg
Copy link

philipahlberg commented Feb 3, 2021

Turns out it's not a rustc bug, just like @jonas-schievink suspected, at least in my case. My issue was that I was using a Docker image built for x86_64 on an aarch64 (M1) machine. I'm still a bit perplexed as to how the build process made it all the way to compiling crates, and also why the bug looked so much like a rustc bug, deep stack trace and everything.

edit: Likely to be a bug in QEMU, in case anyone is curious.

@olliebatch
Copy link

Is there any work arounds for this? I'm trying to compile a rust image on m1 to amd64 and im coming across this same issue but i can't get a workaround.

@coltonweaver
Copy link

Also seeing this issue on an M1 Mac

@vadixidav
Copy link
Contributor

I am running into this issue as well. I am using FROM --platform=linux/amd64 to explicitly pull in an amd64 container while on an aarch64 apple machine. GCC seems to work fine, but Rust seems to hit various memory errors during the compilation process and ultimately fails or stalls indefinitely. This is true for any crate I try to install with cargo install. This may be an issue with QEMU specifically, but I would like it if I could get Rust to work in an amd64 container running on aarch64.

@cdknight
Copy link

These issues (and same conditions, http library) arise when trying to use a chroot (that runs Arch Linux ARM) on an amd64 machine that uses QEMU's userspace binary translator to emulate aarch64 when trying to build a Rust program, although this is probably, as people have mentioned, not a rustc bug.

@Enselic
Copy link
Member

Enselic commented Apr 23, 2024

Triage: Closing, since this is not a rustc bug, and can thus not be fixed in rustc.

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Apr 23, 2024
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

10 participants