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

ICE "broken MIR ... Field projection specified type ... but actual type is ..." comparing type with type as trait #105044

Closed
teor2345 opened this issue Nov 29, 2022 · 8 comments
Labels
C-bug Category: This is a bug. 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

@teor2345
Copy link
Contributor

teor2345 commented Nov 29, 2022

There seems to be a bug in the way that Rust compiles Iterator::flat_map(), in release mode, with complex iterators.

It also triggers on other "type" vs "type as trait" comparisons in the compiler, for example unsized-vec fails with:

error: internal compiler error: broken MIR in DropGlue(DefId(2:2141 ~ core[0ec9]::ptr::drop_in_place), Some(unsized_vec::UnsizedVec<dyn std::fmt::Debug>)) (after phase change to runtime-optimized) at bb0[0]:
                                Field projection `(*_1).field[0]` specified type `unsized_vec::inner::unaligned::UnalignedVecInner<dyn std::fmt::Debug>`, but actual type is `<dyn std::fmt::Debug as unsized_vec::inner::UnsizedVecImpl>::Impl`
   --> /home/dev/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:490:1
    |
490 | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:229:30

error: internal compiler error: broken MIR in DropGlue(DefId(2:2141 ~ core[0ec9]::ptr::drop_in_place), Some(unsized_vec::UnsizedVec<[i32]>)) (after phase change to runtime-optimized) at bb0[0]:
                                Field projection `(*_1).field[0]` specified type `unsized_vec::inner::aligned::AlignedVecInner<[i32]>`, but actual type is `<[i32] as unsized_vec::inner::UnsizedVecImpl>::Impl`
   --> /home/dev/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:490:1

Code

Related crate code:

pub enum Transaction {
    V5 {
        orchard_shielded_data: Option<ShieldedData>,
    },
}

impl Transaction {
    pub fn orchard_shielded_data(&self) -> Option<&ShieldedData> {
        match self {
            // Maybe Orchard shielded data
            Transaction::V5 {
                orchard_shielded_data,
                ..
            } => orchard_shielded_data.as_ref(),
        }
    }

    pub fn orchard_nullifiers(&self) -> impl Iterator<Item = &Nullifier> {
        self.orchard_shielded_data()
            .into_iter()
            .flat_map(ShieldedData::nullifiers)
    }
}

pub struct ShieldedData {
    pub actions: AtLeastOne<AuthorizedAction>,
}

impl ShieldedData {
    pub fn actions(&self) -> impl Iterator<Item = &Action> {
        self.actions.actions()
    }

    pub fn nullifiers(&self) -> impl Iterator<Item = &Nullifier> {
        self.actions().map(|action| &action.nullifier)
    }
}

impl AtLeastOne<AuthorizedAction> {
    pub fn actions(&self) -> impl Iterator<Item = &Action> {
        self.iter()
            .map(|authorized_action| &authorized_action.action)
    }
}

pub struct AuthorizedAction {
    pub action: Action,
}

pub struct Action {
    pub nullifier: (),
}

pub struct AtLeastOne<T> {
    inner: Vec<T>,
}

impl<T> Deref for AtLeastOne<T> {
    type Target = Vec<T>;

    fn deref(&self) -> &Self::Target {
        &self.inner
    }
}

impl<T> AsRef<[T]> for AtLeastOne<T> {
    fn as_ref(&self) -> &[T] {
        self.inner.as_ref()
    }
}

impl<T> IntoIterator for AtLeastOne<T> {
    type Item = T;

    type IntoIter = std::vec::IntoIter<T>;

    fn into_iter(self) -> std::vec::IntoIter<T> {
        self.inner.into_iter()
    }
}

Failing code:

impl Transaction {
    pub fn orchard_nullifiers(&self) -> impl Iterator<Item = &Nullifier> {
        self.orchard_shielded_data()
            .into_iter()
            .flat_map(ShieldedData::nullifiers)
    }
}

    let orchard_nullifier_count = block
        .transactions
        .iter()
        .flat_map(|t| t.orchard_nullifiers()) 
        .count();

    for nullifier in prepared.block.orchard_nullifiers() { }

Workaround:

    pub fn orchard_nullifiers(&self) -> impl Iterator<Item = &orchard::Nullifier> {
        let nullifiers: Vec<_> = self
            .transactions
            .iter()
            .flat_map(|transaction| transaction.orchard_nullifiers())
            .collect();

        nullifiers.into_iter()
    }

    let orchard_nullifier_count: usize = block
        .transactions
        .iter()
        .map(|t| t.orchard_nullifiers().into_iter().count())
        .sum();

Meta

Fails from nightly nightly-2022-11-20 onwards, in commit 2f8d804.

rustc --version --verbose:

rustc 1.67.0-nightly (2585bcea0 2022-11-28)
binary: rustc
commit-hash: 2585bcea0bc2a9c42a4be2c1eba5c61137f2b167
commit-date: 2022-11-28
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

I used these commands to bisect the nightly Rust version:

git clone https://github.com/ZcashFoundation/zebra.git
git checkout a763eec9f3
cd zebra-state

cat << EOF > cargo-build-release.sh
#!/usr/bin/env bash
cargo build --release
EOF
chmod +x cargo-build-release.sh

cargo-bisect-rustc --start=2022-11-07 --regress=ice --script=./cargo-build-release.sh

Zebra needs some build dependencies:
https://github.com/ZcashFoundation/zebra#build-instructions

Regression log:
searched nightlies: from nightly-2022-11-07 to nightly-2022-11-29
regressed nightly: nightly-2022-11-20
searched commit range: b833ad5...c5d82ed
regressed commit: 2f8d804

bisected with cargo-bisect-rustc v0.6.4

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --regress=ice --script=./cargo-build-release.sh 

Analysis

This might be caused by -C linker-plugin-lto or release builds, but I couldn't find an exact set of flags or a minimal example to reproduce it.

cargo build does not fail, either from the individual crate or workspace directory. But cargo build --release and cargo install --git https://github.com/ZcashFoundation/zebra.git zebrad fail.

I tried commenting out my whole .cargo/config.toml, and it didn't make a difference.

Error output

error: internal compiler error: no errors encountered even though `delay_span_bug` issued                
                                                                                                         
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:1718 ~ zebra_state[4d
f4]::service::finalized_state::zebra_db::metrics::block_precommit_metrics), const_param_did: None }) (aft
er phase change to runtime-optimized) at bb128[5]:                                                       
                                Field projection `_37.field[0]` specified type `std::iter::adapters::flat
ten::FlattenCompat<std::iter::Map<std::slice::Iter<'_, std::sync::Arc<zebra_chain::transaction::Transacti
on>>, [closure@zebra-state/src/service/finalized_state/zebra_db/metrics.rs:39:19: 39:22]>, std::iter::Fla
tMap<std::option::IntoIter<&zebra_chain::orchard::ShieldedData>, std::iter::Map<std::iter::Map<std::slice
::Iter<'_, zebra_chain::orchard::AuthorizedAction>, [closure@zebra_chain::orchard::shielded_data::<impl z
ebra_chain::serialization::AtLeastOne<zebra_chain::orchard::AuthorizedAction>>::actions::{closure#0}]>, [
closure@zebra_chain::orchard::ShieldedData::nullifiers::{closure#0}]>, for<'a> fn(&'a zebra_chain::orchar
d::ShieldedData) -> impl std::iter::Iterator<Item = &'a zebra_chain::orchard::Nullifier> {zebra_chain::or
chard::ShieldedData::nullifiers}>>`, but actual type is `std::iter::adapters::flatten::FlattenCompat<std:
:iter::Map<std::slice::Iter<'_, std::sync::Arc<zebra_chain::transaction::Transaction>>, [closure@zebra-st
ate/src/service/finalized_state/zebra_db/metrics.rs:39:19: 39:22]>, <std::iter::FlatMap<std::option::Into
Iter<&zebra_chain::orchard::ShieldedData>, std::iter::Map<std::iter::Map<std::slice::Iter<'_, zebra_chain
::orchard::AuthorizedAction>, [closure@zebra_chain::orchard::shielded_data::<impl zebra_chain::serializat
ion::AtLeastOne<zebra_chain::orchard::AuthorizedAction>>::actions::{closure#0}]>, [closure@zebra_chain::o
rchard::ShieldedData::nullifiers::{closure#0}]>, for<'a> fn(&'a zebra_chain::orchard::ShieldedData) -> im
pl std::iter::Iterator<Item = &'a zebra_chain::orchard::Nullifier> {zebra_chain::orchard::ShieldedData::n
ullifiers}> as std::iter::IntoIterator>::IntoIter>`                                                      
  --> zebra-state/src/service/finalized_state/zebra_db/metrics.rs:36:35 
   |                                                                                                     
36 |       let orchard_nullifier_count = block
   |  ___________________________________^
37 | |         .transactions
38 | |         .iter()
39 | |         .flat_map(|t| t.orchard_nullifiers()) 
40 | |         .count();
   | |________________^
   |
   = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:229:30

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:4282 ~ zebra_state[4d
f4]::service::check::nullifier::no_duplicates_in_finalized_chain), const_param_did: None }) (after phase 
change to runtime-optimized) at bb60[6]:
                                Field projection `(*_128).field[0]` specified type `std::iter::adapters::
flatten::FlattenCompat<std::iter::Map<std::slice::Iter<'_, std::sync::Arc<zebra_chain::transaction::Trans
action>>, [closure@zebra_chain::block::Block::orchard_nullifiers::{closure#0}]>, std::iter::FlatMap<std::
option::IntoIter<&zebra_chain::orchard::ShieldedData>, std::iter::Map<std::iter::Map<std::slice::Iter<'_,
 zebra_chain::orchard::AuthorizedAction>, [closure@zebra_chain::orchard::shielded_data::<impl zebra_chain
::serialization::AtLeastOne<zebra_chain::orchard::AuthorizedAction>>::actions::{closure#0}]>, [closure@ze
bra_chain::orchard::ShieldedData::nullifiers::{closure#0}]>, for<'a> fn(&'a zebra_chain::orchard::Shielde
dData) -> impl std::iter::Iterator<Item = &'a zebra_chain::orchard::Nullifier> {zebra_chain::orchard::Shi
eldedData::nullifiers}>>`, but actual type is `std::iter::adapters::flatten::FlattenCompat<std::iter::Map
<std::slice::Iter<'_, std::sync::Arc<zebra_chain::transaction::Transaction>>, [closure@zebra_chain::block
::Block::orchard_nullifiers::{closure#0}]>, <std::iter::FlatMap<std::option::IntoIter<&zebra_chain::orcha
rd::ShieldedData>, std::iter::Map<std::iter::Map<std::slice::Iter<'_, zebra_chain::orchard::AuthorizedAct
ion>, [closure@zebra_chain::orchard::shielded_data::<impl zebra_chain::serialization::AtLeastOne<zebra_ch
ain::orchard::AuthorizedAction>>::actions::{closure#0}]>, [closure@zebra_chain::orchard::ShieldedData::nu
llifiers::{closure#0}]>, for<'a> fn(&'a zebra_chain::orchard::ShieldedData) -> impl std::iter::Iterator<I
tem = &'a zebra_chain::orchard::Nullifier> {zebra_chain::orchard::ShieldedData::nullifiers}> as std::iter
::IntoIterator>::IntoIter>`
  --> zebra-state/src/service/check/nullifier.rs:48:22
   |
48 |     for nullifier in prepared.block.orchard_nullifiers() {
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:229:30]

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1609:13
Backtrace

stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::flush_delayed::<alloc::vec::Vec<rustc_errors::diagnostic::Diagnostic>
, &str>
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place::<rustc_session::parse::ParseSess>
   5: core::ptr::drop_in_place::<rustc_session::session::Session>
   6: core::ptr::drop_in_place::<rustc_interface::interface::Compiler>
   7: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interf
ace::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_c
ompiler::{closure#1}>::{closure#0}::{closure#0}>
   8: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler
<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{clos
ure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: compiler flags: --crate-type lib -C opt-level=3 -C panic=abort -C linker-plugin-lto -C debuginfo=1 
-C debug-assertions=on

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

query stack during panic:
end of query stack
error: could not compile `zebra-state`

@teor2345 teor2345 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 Nov 29, 2022
teor2345 added a commit to ZcashFoundation/zebra that referenced this issue Nov 29, 2022
@teor2345
Copy link
Contributor Author

I found a workaround, but I still couldn't find a minimal example.

@Noratrieb
Copy link
Member

Out of the rollup, it was probably caused by #104411? cc @lcnr

@Millione
Copy link

Millione commented Nov 29, 2022

I think I encountered the same ICE bug, and still can't find a minimal reproduce example.

Error output

warning: Error finalizing incremental compilation session directory `/data00/home/liujie.roger/rust/git/volo/target/debug/incremental/hello_grpc_server-2r9arx04lojyo/s-gfv6wd3lvx-9bb9z2-working`: No such file or directory (os error 2)

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in DropGlue(DefId(2:2801 ~ core[bc14]::ptr::drop_in_place), Some(volo_grpc::codegen::hyper::proto::h1::dispatch::Server<volo::service::Tower<volo_grpc::server::meta::MetaService<volo_grpc::server::Router>, [closure@volo_grpc::server::Server<volo::layer::Identity>::run<volo::net::Address>::{closure#0}::{closure#0}], volo_grpc::context::ServerContext, http::request::Request<volo_grpc::codegen::hyper::body::body::Body>>, volo_grpc::codegen::hyper::body::body::Body>)) (after phase change to runtime-optimized) at bb0[0]:
                                Field projection `(*_1).field[0]` specified type `std::pin::Pin<std::boxed::Box<std::option::Option<[async block@<volo::service::Tower<volo_grpc::server::meta::MetaService<volo_grpc::server::Router>, [closure@volo_grpc::server::Server<volo::layer::Identity>::run<volo::net::Address>::{closure#0}::{closure#0}], volo_grpc::context::ServerContext, http::request::Request<volo_grpc::codegen::hyper::body::body::Body>> as tower_service::Service<http::request::Request<volo_grpc::codegen::hyper::body::body::Body>>>::call::{closure#0}]>>>`, but actual type is `std::pin::Pin<std::boxed::Box<std::option::Option<<volo::service::Tower<volo_grpc::server::meta::MetaService<volo_grpc::server::Router>, [closure@volo_grpc::server::Server<volo::layer::Identity>::run<volo::net::Address>::{closure#0}::{closure#0}], volo_grpc::context::ServerContext, http::request::Request<volo_grpc::codegen::hyper::body::body::Body>> as volo_grpc::codegen::hyper::service::http::HttpService<volo_grpc::codegen::hyper::body::body::Body>>::Future>>>`
   --> /data00/home/liujie.roger/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:490:1
    |
490 | pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:229:30

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1609:13
stack backtrace:
   0:     0x7fd67761d20a - std::backtrace_rs::backtrace::libunwind::trace::h5d63982369f255be
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fd67761d20a - std::backtrace_rs::backtrace::trace_unsynchronized::h3f0ca420a5fce959
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fd67761d20a - std::sys_common::backtrace::_print_fmt::hb06d2f24224d5008
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fd67761d20a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3ab5a4a02080cf95
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fd677b2212e - core::fmt::write::h7d275b25684d2f4b
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/core/src/fmt/mod.rs:1208:17
   5:     0x7fd6776114d5 - std::io::Write::write_fmt::habd0270971df3efd
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/std/src/io/mod.rs:1682:15
   6:     0x7fd67761cfd5 - std::sys_common::backtrace::_print::h61bb07d45642a6b0
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7fd67761cfd5 - std::sys_common::backtrace::print::h5d41efe8a7680c9e
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7fd67761f33f - std::panicking::default_hook::{{closure}}::he45a8add8cd6c157
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/std/src/panicking.rs:267:22
   9:     0x7fd67761f07b - std::panicking::default_hook::h5bdfb218ae8ccf1a
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/std/src/panicking.rs:286:9
  10:     0x7fd676864e54 - rustc_driver[9b4589fbd0ca3010]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fd67761fb3d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hc626e6f5815a4649
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/alloc/src/boxed.rs:2032:9
  12:     0x7fd67761fb3d - std::panicking::rust_panic_with_hook::haa2a8406479dd255
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/std/src/panicking.rs:692:13
  13:     0x7fd67689d8d1 - std[85b9d86509865b2b]::panicking::begin_panic::<rustc_errors[7d36137f8dd089c7]::ExplicitBug>::{closure#0}
  14:     0x7fd67689c196 - std[85b9d86509865b2b]::sys_common::backtrace::__rust_end_short_backtrace::<std[85b9d86509865b2b]::panicking::begin_panic<rustc_errors[7d36137f8dd089c7]::ExplicitBug>::{closure#0}, !>
  15:     0x7fd676894816 - std[85b9d86509865b2b]::panicking::begin_panic::<rustc_errors[7d36137f8dd089c7]::ExplicitBug>
  16:     0x7fd676898026 - std[85b9d86509865b2b]::panic::panic_any::<rustc_errors[7d36137f8dd089c7]::ExplicitBug>
  17:     0x7fd675d7fe86 - <rustc_errors[7d36137f8dd089c7]::HandlerInner>::flush_delayed::<alloc[edfeea1ed307d55e]::vec::Vec<rustc_errors[7d36137f8dd089c7]::diagnostic::Diagnostic>, &str>
  18:     0x7fd675d7f18b - <rustc_errors[7d36137f8dd089c7]::HandlerInner as core[bc14861035b9f032]::ops::drop::Drop>::drop
  19:     0x7fd675ad2a7e - core[bc14861035b9f032]::ptr::drop_in_place::<rustc_session[74924a319b9741d3]::parse::ParseSess>
  20:     0x7fd675ac373f - core[bc14861035b9f032]::ptr::drop_in_place::<rustc_session[74924a319b9741d3]::session::Session>
  21:     0x7fd675ac3470 - core[bc14861035b9f032]::ptr::drop_in_place::<rustc_interface[4869d893f0e6a446]::interface::Compiler>
  22:     0x7fd675ac257e - rustc_span[fe585761646e9245]::with_source_map::<core[bc14861035b9f032]::result::Result<(), rustc_errors[7d36137f8dd089c7]::ErrorGuaranteed>, rustc_interface[4869d893f0e6a446]::interface::run_compiler<core[bc14861035b9f032]::result::Result<(), rustc_errors[7d36137f8dd089c7]::ErrorGuaranteed>, rustc_driver[9b4589fbd0ca3010]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  23:     0x7fd675ac1eb5 - <scoped_tls[88353d2f7a38210b]::ScopedKey<rustc_span[fe585761646e9245]::SessionGlobals>>::set::<rustc_interface[4869d893f0e6a446]::interface::run_compiler<core[bc14861035b9f032]::result::Result<(), rustc_errors[7d36137f8dd089c7]::ErrorGuaranteed>, rustc_driver[9b4589fbd0ca3010]::run_compiler::{closure#1}>::{closure#0}, core[bc14861035b9f032]::result::Result<(), rustc_errors[7d36137f8dd089c7]::ErrorGuaranteed>>
  24:     0x7fd675ac14a2 - std[85b9d86509865b2b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[4869d893f0e6a446]::util::run_in_thread_pool_with_globals<rustc_interface[4869d893f0e6a446]::interface::run_compiler<core[bc14861035b9f032]::result::Result<(), rustc_errors[7d36137f8dd089c7]::ErrorGuaranteed>, rustc_driver[9b4589fbd0ca3010]::run_compiler::{closure#1}>::{closure#0}, core[bc14861035b9f032]::result::Result<(), rustc_errors[7d36137f8dd089c7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bc14861035b9f032]::result::Result<(), rustc_errors[7d36137f8dd089c7]::ErrorGuaranteed>>
  25:     0x7fd675ac11b8 - <<std[85b9d86509865b2b]::thread::Builder>::spawn_unchecked_<rustc_interface[4869d893f0e6a446]::util::run_in_thread_pool_with_globals<rustc_interface[4869d893f0e6a446]::interface::run_compiler<core[bc14861035b9f032]::result::Result<(), rustc_errors[7d36137f8dd089c7]::ErrorGuaranteed>, rustc_driver[9b4589fbd0ca3010]::run_compiler::{closure#1}>::{closure#0}, core[bc14861035b9f032]::result::Result<(), rustc_errors[7d36137f8dd089c7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[bc14861035b9f032]::result::Result<(), rustc_errors[7d36137f8dd089c7]::ErrorGuaranteed>>::{closure#1} as core[bc14861035b9f032]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:     0x7fd677626d73 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h87f315d78631c89a
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/alloc/src/boxed.rs:2000:9
  27:     0x7fd677626d73 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h44e64edef3723eae
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/alloc/src/boxed.rs:2000:9
  28:     0x7fd677626d73 - std::sys::unix::thread::Thread::new::thread_start::h6b1af1d92f601469
                               at /rustc/2585bcea0bc2a9c42a4be2c1eba5c61137f2b167/library/std/src/sys/unix/thread.rs:108:17
  29:     0x7fd672fcd4a4 - start_thread
                               at /build/glibc-77giwP/glibc-2.24/nptl/pthread_create.c:456
  30:     0x7fd672d0fd0f - __GI___clone
                               at /build/glibc-77giwP/glibc-2.24/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97
  31:                0x0 - <unknown>

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.67.0-nightly (2585bcea0 2022-11-28) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack

@MilkFather
Copy link

Perhaps #105009 shares the same problem? Same regressed nightly build, same ice error ("delay_span_bug" + broken MIR).

@lcnr lcnr added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Nov 29, 2022
@teor2345 teor2345 changed the title ICE "broken MIR ... Field projection specified type ... but actual type is ..." on iterator ICE "broken MIR ... Field projection specified type ... but actual type is ..." on flat_map() iterator Nov 29, 2022
mergify bot pushed a commit to ZcashFoundation/zebra that referenced this issue Nov 30, 2022
* Remove an unused async track_caller which will soon become a warning

* Explicitly drop unused futures

* Work around a compiler panic (ICE) with flat_map()

rust-lang/rust#105044

* Remove a redundant into_iter()

* allow(clippy::needless_collect)
@Jules-Bertholet
Copy link
Contributor

Jules-Bertholet commented Dec 3, 2022

unsized-vec also triggers the same ICE upon cargo test, with the same bisection result.

@teor2345 teor2345 changed the title ICE "broken MIR ... Field projection specified type ... but actual type is ..." on flat_map() iterator ICE "broken MIR ... Field projection specified type ... but actual type is ..." comparing type with type as trait Dec 4, 2022
@teor2345
Copy link
Contributor Author

teor2345 commented Dec 4, 2022

unsized-vec also triggers the same ICE upon cargo test, with the same bisection result.

Do you have a minimal example?

I had trouble getting one from Zebra, because the error happened when calling a large chain of iterators.

(I've added the specific unsized-vec error message to the description.)

@apiraino
Copy link
Contributor

apiraino commented Dec 7, 2022

Perhaps #105009 shares the same problem? Same regressed nightly build, same ice error ("delay_span_bug" + broken MIR).

I also believe this is a duplicate of #105009 (I'm pointing other issues there for a chance of a smaller MCVE) and close this.

@apiraino
Copy link
Contributor

apiraino commented Dec 8, 2022

closing in favor of #105009

@apiraino apiraino closed this as not planned Won't fix, can't repro, duplicate, stale Dec 8, 2022
teor2345 added a commit to ZcashFoundation/zebra that referenced this issue Feb 6, 2023
* Remove an unused async track_caller which will soon become a warning

* Explicitly drop unused futures

* Work around a compiler panic (ICE) with flat_map()

rust-lang/rust#105044

* Remove a redundant into_iter()

* allow(clippy::needless_collect)
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. 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

7 participants