rust-lang / rust

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

Panic while compiling http-body v0.4.6 with rustc 1.83.0-nightly (7042c269c 2024-09-23) #130769

Closed arpankapoor closed 2 months ago

arpankapoor commented 2 months ago

Code

Clone http-body, checkout v0.4.6 and compile in release mode:

$ git clone https://github.com/hyperium/http-body.git
$ cd http-body
$ git checkout v0.4.6
$ cargo build --release

Meta

rustc --version --verbose:

rustc 1.83.0-nightly (7042c269c 2024-09-23)
binary: rustc
commit-hash: 7042c269c166191cd5d8daf0409890903df7af57
commit-date: 2024-09-23
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

Error output

thread 'rustc' panicked at compiler/rustc_mir_transform/src/validate.rs:152:26:
broken MIR in Item(DefId(0:23 ~ http_body[d100]::collect::{impl#1}::poll)) (after phase change to runtime-optimized) at bb22[2]:
Normal edge to BasicBlockData { statements: [StorageDead(_46)], terminator: Some(Terminator { source_info: SourceInfo { span: src/collect.rs:69:13: 69:14 (#0), scope: scope[1] }, kind: goto -> bb41 }), is_cleanup: false } violates unwind invariants (cleanup true -> false)
stack backtrace:
   0:     0x7fe9e4c02f25 - std::backtrace::Backtrace::create::h8d365723131839b0
   1:     0x7fe9e32738a5 - std::backtrace::Backtrace::force_capture::ha8b2c128ac653152
   2:     0x7fe9e2382ea4 - std[25b33fdea409b280]::panicking::update_hook::<alloc[1694921db2598cc8]::boxed::Box<rustc_driver_impl[91319f0e19a4d720]::install_ice_hook::{closure#0}>>::{closure#0}
   3:     0x7fe9e328b018 - std::panicking::rust_panic_with_hook::hfa739d875be2cf67
   4:     0x7fe9e328adea - std::panicking::begin_panic_handler::{{closure}}::h9a9134f6e05b41bd
   5:     0x7fe9e32887d9 - std::sys::backtrace::__rust_end_short_backtrace::h35fa4dfdd9fe9e0c
   6:     0x7fe9e328aaac - rust_begin_unwind
   7:     0x7fe9e0a9e7b0 - core::panicking::panic_fmt::hc3e7c6c5c469a97f
   8:     0x7fe9e10b311a - <rustc_mir_transform[2c59a960358d0625]::validate::Validator as rustc_mir_transform[2c59a960358d0625]::pass_manager::MirPass>::run_pass
   9:     0x7fe9e3a0dc64 - rustc_mir_transform[2c59a960358d0625]::pass_manager::run_passes_inner
  10:     0x7fe9e4403922 - rustc_mir_transform[2c59a960358d0625]::optimized_mir
  11:     0x7fe9e44021db - rustc_query_impl[16add4a89c515f02]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[16add4a89c515f02]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5962dfe9f3174182]::query::erase::Erased<[u8; 8usize]>>
  12:     0x7fe9e3a31eae - rustc_query_system[cd92c81c02f5c019]::query::plumbing::try_execute_query::<rustc_query_impl[16add4a89c515f02]::DynamicConfig<rustc_query_system[cd92c81c02f5c019]::query::caches::DefIdCache<rustc_middle[5962dfe9f3174182]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[16add4a89c515f02]::plumbing::QueryCtxt, false>
  13:     0x7fe9e3a3145f - rustc_query_impl[16add4a89c515f02]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  14:     0x7fe9e440e963 - rustc_middle[5962dfe9f3174182]::query::plumbing::query_get_at::<rustc_query_system[cd92c81c02f5c019]::query::caches::DefIdCache<rustc_middle[5962dfe9f3174182]::query::erase::Erased<[u8; 8usize]>>>
  15:     0x7fe9e4416305 - <rustc_metadata[bda71c6b2cfd99ea]::rmeta::encoder::EncodeContext>::encode_crate_root
  16:     0x7fe9e4ab8ad3 - rustc_metadata[bda71c6b2cfd99ea]::rmeta::encoder::encode_metadata
  17:     0x7fe9e4ac0f54 - rustc_metadata[bda71c6b2cfd99ea]::fs::encode_and_write_metadata
  18:     0x7fe9e4abfd43 - <rustc_interface[1294e3f809d58823]::queries::Linker>::codegen_and_build_linker
  19:     0x7fe9e472a34b - rustc_interface[1294e3f809d58823]::interface::run_compiler::<core[1e18fbba9f4dcc19]::result::Result<(), rustc_span[d14b83658cea8543]::ErrorGuaranteed>, rustc_driver_impl[91319f0e19a4d720]::run_compiler::{closure#0}>::{closure#1}
  20:     0x7fe9e47bf210 - std[25b33fdea409b280]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1294e3f809d58823]::util::run_in_thread_with_globals<rustc_interface[1294e3f809d58823]::util::run_in_thread_pool_with_globals<rustc_interface[1294e3f809d58823]::interface::run_compiler<core[1e18fbba9f4dcc19]::result::Result<(), rustc_span[d14b83658cea8543]::ErrorGuaranteed>, rustc_driver_impl[91319f0e19a4d720]::run_compiler::{closure#0}>::{closure#1}, core[1e18fbba9f4dcc19]::result::Result<(), rustc_span[d14b83658cea8543]::ErrorGuaranteed>>::{closure#0}, core[1e18fbba9f4dcc19]::result::Result<(), rustc_span[d14b83658cea8543]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1e18fbba9f4dcc19]::result::Result<(), rustc_span[d14b83658cea8543]::ErrorGuaranteed>>
  21:     0x7fe9e47bf87a - <<std[25b33fdea409b280]::thread::Builder>::spawn_unchecked_<rustc_interface[1294e3f809d58823]::util::run_in_thread_with_globals<rustc_interface[1294e3f809d58823]::util::run_in_thread_pool_with_globals<rustc_interface[1294e3f809d58823]::interface::run_compiler<core[1e18fbba9f4dcc19]::result::Result<(), rustc_span[d14b83658cea8543]::ErrorGuaranteed>, rustc_driver_impl[91319f0e19a4d720]::run_compiler::{closure#0}>::{closure#1}, core[1e18fbba9f4dcc19]::result::Result<(), rustc_span[d14b83658cea8543]::ErrorGuaranteed>>::{closure#0}, core[1e18fbba9f4dcc19]::result::Result<(), rustc_span[d14b83658cea8543]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[1e18fbba9f4dcc19]::result::Result<(), rustc_span[d14b83658cea8543]::ErrorGuaranteed>>::{closure#1} as core[1e18fbba9f4dcc19]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  22:     0x7fe9e47bfc6b - std::sys::pal::unix::thread::Thread::new::thread_start::h9c0c387d4b02e16a
  23:     0x7fe9e5fd16d7 - start_thread
  24:     0x7fe9e605560c - __clone3
  25:                0x0 - <unknown>

rustc version: 1.83.0-nightly (7042c269c 2024-09-23)
platform: x86_64-unknown-linux-gnu

query stack during panic:
#0 [optimized_mir] optimizing MIR for `collect::<impl at src/collect.rs:37:1: 37:36>::poll`
end of query stack
Backtrace

``` ```

theemathas commented 2 months ago

Minimized:

use std::task::Poll;

pub fn poll(val: Poll<Result<Option<Vec<u8>>, u8>>) {
    match val {
        Poll::Ready(Ok(Some(_trailers))) => {}
        Poll::Ready(Err(_err)) => {}
        Poll::Ready(Ok(None)) => {}
        Poll::Pending => {}
    }
}

Run cargo +nightly build --release to reproduce the ICE

theemathas commented 2 months ago

@rustbot labels +regression-from-stable-to-nightly

jieyouxu commented 2 months ago

searched nightlies: from nightly-2024-09-20 to nightly-2024-09-24 regressed nightly: nightly-2024-09-24 searched commit range: https://github.com/rust-lang/rust/compare/6c6d210089e4589afee37271862b9f88ba1d7755...7042c269c166191cd5d8daf0409890903df7af57 regressed commit: https://github.com/rust-lang/rust/commit/a772336fb3fbd1fe4493077fcfe04e0221296a99

bisected with cargo-bisect-rustc v0.6.8 Host triple: aarch64-unknown-linux-gnu Reproduce with: ```bash cargo bisect-rustc --regress=ice -- build --release ```
jieyouxu commented 2 months ago

Might be #129047 cc @DianQK

apiraino commented 2 months ago

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-critical

jieyouxu commented 2 months ago

Trying to figure out what flags I need to pass to make rustc ICE, -C opt-level=3 doesn't seem to be sufficient alone, checking what cargo release profile sets. Nevermind an unrelated erorr was masking the ICE in the test.

jieyouxu commented 2 months ago

Haven't closed Compiler panik #130771 as duplicate, as while it is probably caused by changes in https://github.com/rust-lang/rust/pull/129047, it might not be due to the exact same code path.

HTGAzureX1212 commented 2 months ago

Just encountered this now, posting the GitHub Actions log: https://github.com/HTGAzureX1212/HarTex/actions/runs/11014828619/job/30586387526

This seems to not only be happening to http-body but to some other crates as well (in the log above, twilight-http).

theemathas commented 2 months ago

The problematic part of twilight-http has the exact same pattern of nested match patterns https://github.com/twilight-rs/twilight/blob/9147a49e2f96f4cde9be3fc48dda42dd5fecd3e1/twilight-http/src/response/future.rs#L84

DianQK commented 2 months ago

130786 should fix this. I will rebase after #130775 merged.

wesleywiser commented 2 months ago

Fixed by #130775 which reverted the change and added the minimized reproducer to the test suite. Thanks @jieyouxu!