rust-lang / rust

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

ICE: index out of bounds, snapshot vec #122823

Open matthiaskrgr opened 8 months ago

matthiaskrgr commented 8 months ago

Code

use std::vec::Vec;
use std::iter::Peekable;

pub fn main() {
    let packet = decode(vec![1,0,1,0]);
}

pub fn decode(bitstream: Vec<u64>) -> Packet {
    let mut bitstream_itr = bitstream.into_iter().peekable();
    return match decode_packet(&mut bitstream_itr) {
        Some(p) => p,
        None    => panic!("expected outer packet"),
    }
}

pub fn decode_packets<I: Iterator<Item = u64>>(itr: &mut Peekable<I>) -> Vec<Packet> {
    let mut res = Vec::new();
    loop {
        match decode_packet(itr) {
            Some(p) => { res.push(p); },
            None    => break
        }
    }

    return res;
}

pub fn decode_packet<I: Iterator<Item = u64>>(itr: &mut Peekable<I>) -> Option<Packet> {
    // get version digits
    let version = extend_number(0, itr, 3)?;
    let type_id = extend_number(0, itr, 3)?;
    return operator_packet(version, type_id, itr);
}

pub fn operator_packet<I: Iterator<Item = u64>>(version: u64, type_id: u64, itr: &mut Peekable<I>) -> Option<Packet> {
    let p = OperatorPacket {
        version: version,
        type_id: type_id,
        packets: decode_packets(&mut itr.take(0).peekable()),
    };

    return Some(Packet::Operator(p));
}

pub fn extend_number<I: Iterator<Item = u64>>(num: u64, itr: &mut Peekable<I>, take: u64) -> Option<u64> {
    let mut value = num;
    for _ in 0..take {
        value *= 2;
        value += itr.next()?;
    }

    return Some(value);
}

#[derive(Debug)]
pub enum Packet {
    Operator(OperatorPacket),
}

#[derive(Debug)]
pub struct OperatorPacket {
    version: u64,
    type_id: u64,
    packets: Vec<Packet>
}

Meta

rustc --version --verbose:

Error output

warning: the item `Vec` is imported redundantly
   --> ./92004.rs:1:5
    |
1   | use std::vec::Vec;
    |     ^^^^^^^^^^^^^
    |
   ::: /home/gh-matthiaskrgr/.rustup/toolchains/master/lib/rustlib/src/rust/library/std/src/prelude/mod.rs:105:13
    |
105 |     pub use super::v1::*;
    |             --------- the item `Vec` is already defined here
    |
    = note: `#[warn(unused_imports)]` on by default

warning: unused variable: `packet`
 --> ./92004.rs:5:9
  |
5 |     let packet = decode(vec![1,0,1,0]);
  |         ^^^^^^ help: if this is intentional, prefix it with an underscore: `_packet`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: fields `version`, `type_id`, and `packets` are never read
  --> ./92004.rs:62:5
   |
61 | pub struct OperatorPacket {
   |            -------------- fields in this struct
62 |     version: u64,
   |     ^^^^^^^
63 |     type_id: u64,
   |     ^^^^^^^
64 |     packets: Vec<Packet>
   |     ^^^^^^^
   |
   = note: `OperatorPacket` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
   = note: `#[warn(dead_code)]` on by default
Backtrace

``` thread 'rustc' panicked at /rust/deps/ena-0.14.2/src/snapshot_vec.rs:199:10: index out of bounds: the len is 0 but the index is 0 stack backtrace: 0: 0x7f0eb954ffa5 - std::backtrace_rs::backtrace::libunwind::trace::he2d7e0b4ceae414e at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5 1: 0x7f0eb954ffa5 - std::backtrace_rs::backtrace::trace_unsynchronized::hdaffc19ffc09bde8 at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f0eb954ffa5 - std::sys_common::backtrace::_print_fmt::hd4fb259cf7d0e8e3 at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/sys_common/backtrace.rs:68:5 3: 0x7f0eb954ffa5 - ::fmt::h762a4aab0b589a4c at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7f0eb95a0feb - core::fmt::rt::Argument::fmt::hf72a54190dc4baa2 at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/core/src/fmt/rt.rs:142:9 5: 0x7f0eb95a0feb - core::fmt::write::h24784e35e0380a3e at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/core/src/fmt/mod.rs:1153:17 6: 0x7f0eb9544d3f - std::io::Write::write_fmt::hb24b3a89fb200ddb at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/io/mod.rs:1843:15 7: 0x7f0eb954fd7e - std::sys_common::backtrace::_print::h0e48be87587a473e at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7f0eb954fd7e - std::sys_common::backtrace::print::h078f9026890c0b12 at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f0eb95529f9 - std::panicking::default_hook::{{closure}}::h19f2ef2f452cda43 10: 0x7f0eb9552763 - std::panicking::default_hook::h0e9944bdb39da579 at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/panicking.rs:292:9 11: 0x7f0eb5fceb9f - std[8c61ae4e9dc6f99a]::panicking::update_hook::>::{closure#0} 12: 0x7f0eb9553150 - as core::ops::function::Fn>::call::hfbae6ab25830f7c8 at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/alloc/src/boxed.rs:2029:9 13: 0x7f0eb9553150 - std::panicking::rust_panic_with_hook::h33fb6d06d73e30d6 at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/panicking.rs:783:13 14: 0x7f0eb9552ea6 - std::panicking::begin_panic_handler::{{closure}}::he600efcf8c3cf12a at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/panicking.rs:657:13 15: 0x7f0eb9550469 - std::sys_common::backtrace::__rust_end_short_backtrace::he9a6cadc9215c56f at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/sys_common/backtrace.rs:171:18 16: 0x7f0eb9552bd7 - rust_begin_unwind at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/panicking.rs:645:5 17: 0x7f0eb959d486 - core::panicking::panic_fmt::hd936952a5927c902 at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/core/src/panicking.rs:72:14 18: 0x7f0eb959d6a7 - core::panicking::panic_bounds_check::h6249d6f447df14c3 at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/core/src/panicking.rs:205:5 19: 0x7f0eb86395e8 - >, &mut rustc_infer[d94298ef228ce58b]::infer::snapshot::undo_log::InferCtxtUndoLogs>>>::uninlined_get_root_key.llvm.556618795195803917.cold 20: 0x7f0eb49d4cee - >::fold_ty 21: 0x7f0eb49d52a5 - >::fold_ty 22: 0x7f0eb49d52a5 - >::fold_ty 23: 0x7f0eb77853c5 - >::try_fold_predicate 24: 0x7f0eb48e20af - rustc_ty_utils[818eeb7f16c0446]::common_traits::is_copy_raw 25: 0x7f0eb78c6265 - rustc_query_impl[103b6eeeb95b654e]::plumbing::__rust_begin_short_backtrace::> 26: 0x7f0eb78c5953 - rustc_query_system[72071770fb0f9e7d]::query::plumbing::try_execute_query::, rustc_middle[dd5b3b6f0751d1e7]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[103b6eeeb95b654e]::plumbing::QueryCtxt, false> 27: 0x7f0eb78c560e - rustc_query_impl[103b6eeeb95b654e]::query_impl::is_copy_raw::get_query_non_incr::__rust_end_short_backtrace 28: 0x7f0eb78c6b18 - rustc_ty_utils[818eeb7f16c0446]::needs_drop::needs_drop_raw 29: 0x7f0eb78c6547 - rustc_query_impl[103b6eeeb95b654e]::plumbing::__rust_begin_short_backtrace::> 30: 0x7f0eb78c58fb - rustc_query_system[72071770fb0f9e7d]::query::plumbing::try_execute_query::, rustc_middle[dd5b3b6f0751d1e7]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[103b6eeeb95b654e]::plumbing::QueryCtxt, false> 31: 0x7f0eb78c554e - rustc_query_impl[103b6eeeb95b654e]::query_impl::needs_drop_raw::get_query_non_incr::__rust_end_short_backtrace 32: 0x7f0eb4e6510a - rustc_ty_utils[818eeb7f16c0446]::instance::resolve_instance 33: 0x7f0eb79a8145 - rustc_query_impl[103b6eeeb95b654e]::plumbing::__rust_begin_short_backtrace::> 34: 0x7f0eb79a8484 - rustc_query_system[72071770fb0f9e7d]::query::plumbing::try_execute_query::)>, rustc_middle[dd5b3b6f0751d1e7]::query::erase::Erased<[u8; 32usize]>>, false, false, false>, rustc_query_impl[103b6eeeb95b654e]::plumbing::QueryCtxt, false> 35: 0x7f0eb79a80dd - rustc_query_impl[103b6eeeb95b654e]::query_impl::resolve_instance::get_query_non_incr::__rust_end_short_backtrace 36: 0x7f0eb79aa466 - ::resolve_drop_in_place 37: 0x7f0eb4afc13f - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec::{closure#0} 38: 0x7f0eb81a0392 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 39: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 40: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 41: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 42: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 43: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 44: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 45: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 46: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 47: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 48: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 49: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 50: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 51: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 52: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 53: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 54: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 55: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 56: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 57: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 58: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 59: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 60: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 61: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 62: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 63: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 64: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 65: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 66: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 67: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 68: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 69: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 70: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 71: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 72: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 73: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 74: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 75: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 76: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 77: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 78: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 79: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 80: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 81: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 82: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 83: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 84: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 85: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 86: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 87: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 88: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 89: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 90: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 91: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 92: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 93: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 94: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 95: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 96: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 97: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 98: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 99: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 100: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 101: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 102: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 103: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 104: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 105: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 106: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 107: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 108: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 109: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 110: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 111: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 112: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 113: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 114: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 115: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 116: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 117: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 118: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 119: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 120: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 121: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 122: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 123: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 124: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 125: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 126: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 127: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 128: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 129: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 130: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 131: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 132: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 133: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 134: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 135: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 136: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 137: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 138: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 139: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 140: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 141: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 142: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 143: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 144: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 145: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 146: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 147: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 148: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 149: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 150: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 151: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 152: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 153: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 154: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 155: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 156: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 157: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 158: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 159: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 160: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 161: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 162: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 163: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 164: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 165: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 166: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 167: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 168: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 169: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 170: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 171: 0x7f0eb81a0d50 - rustc_monomorphize[cce86ba432f7b2a0]::collector::collect_items_rec 172: 0x7f0eb8198df6 - rustc_monomorphize[cce86ba432f7b2a0]::partitioning::collect_and_partition_mono_items 173: 0x7f0eb81983ee - rustc_query_impl[103b6eeeb95b654e]::plumbing::__rust_begin_short_backtrace::> 174: 0x7f0eb81983d3 - >::call_once 175: 0x7f0eb823d6ce - rustc_query_system[72071770fb0f9e7d]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[103b6eeeb95b654e]::plumbing::QueryCtxt, false> 176: 0x7f0eb823d3c5 - rustc_query_impl[103b6eeeb95b654e]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace 177: 0x7f0eb82d0af0 - rustc_codegen_ssa[5284b279088479b5]::base::codegen_crate:: 178: 0x7f0eb82c3e29 - ::codegen_crate 179: 0x7f0eb82c379f - rustc_interface[f82c04bf8d9e9e5f]::passes::start_codegen 180: 0x7f0eb82c2f33 - ::codegen_and_build_linker 181: 0x7f0eb80905d6 - rustc_interface[f82c04bf8d9e9e5f]::interface::run_compiler::, rustc_driver_impl[50dc0f0ce2053d12]::run_compiler::{closure#0}>::{closure#0} 182: 0x7f0eb815cac5 - std[8c61ae4e9dc6f99a]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[50dc0f0ce2053d12]::run_compiler::{closure#0}>::{closure#0}, core[db3fd14870e16b34]::result::Result<(), rustc_span[df0a12af4122e9fb]::ErrorGuaranteed>>::{closure#0}, core[db3fd14870e16b34]::result::Result<(), rustc_span[df0a12af4122e9fb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[db3fd14870e16b34]::result::Result<(), rustc_span[df0a12af4122e9fb]::ErrorGuaranteed>> 183: 0x7f0eb815c8f2 - <::spawn_unchecked_, rustc_driver_impl[50dc0f0ce2053d12]::run_compiler::{closure#0}>::{closure#0}, core[db3fd14870e16b34]::result::Result<(), rustc_span[df0a12af4122e9fb]::ErrorGuaranteed>>::{closure#0}, core[db3fd14870e16b34]::result::Result<(), rustc_span[df0a12af4122e9fb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[db3fd14870e16b34]::result::Result<(), rustc_span[df0a12af4122e9fb]::ErrorGuaranteed>>::{closure#1} as core[db3fd14870e16b34]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 184: 0x7f0eb955c919 - as core::ops::function::FnOnce>::call_once::h8bca559b886796e2 at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/alloc/src/boxed.rs:2015:9 185: 0x7f0eb955c919 - as core::ops::function::FnOnce>::call_once::h6921d0e12fce02bd at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/alloc/src/boxed.rs:2015:9 186: 0x7f0eb955c919 - std::sys::pal::unix::thread::Thread::new::thread_start::hba4f4afbe9e3ea3d at /rustc/df8ac8f1d74cffb96a93ae702d16e224f5b9ee8c/library/std/src/sys/pal/unix/thread.rs:108:17 187: 0x7f0eb2c94ac3 - start_thread at ./nptl/pthread_create.c:442:8 188: 0x7f0eb2d26850 - __GI___clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81 189: 0x0 - error: 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: please attach the file at `/home/gh-matthiaskrgr/vcs/github/glacier2/fixed/rustc-ice-2024-03-21T11_22_20-907115.txt` to your bug report query stack during panic: thread panicked while processing panic. aborting. Aborted (core dumped) ```

matthiaskrgr commented 8 months ago

This used to


error[E0275]: overflow evaluating the requirement `&mut Peekable<std::vec::IntoIter<u64>>: Sized`
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`92004`)
  = note: required for `std::iter::Take<&mut Peekable<std::vec::IntoIter<u64>>>` to implement `Iterator`
  = note: 128 redundant requirements hidden
  = note: required for `&mut Peekable<Take<&mut Peekable<Take<&mut Peekable<Take<&mut Peekable<Take<&mut Peekable<Take<&mut Peekable<Take<&mut Peekable<Take<&mut Peekable<Take<&mut Peekable<Take<&mut Peekable<Take<&mut Peekable<Take<&mut Peekable<Take<&mut Peekable<Take<&mut ...>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Iterator`
  = note: the full name for the type has been written to '92004.long-type-4628559490788026519.txt'
  = note: consider using `--verbose` to print the full type name to the console

error: aborting due to 1 previous error; 3 warnings emitted

For more information about this error, try `rustc --explain E0275`.

This is a regression from #122568 cc @RalfJung

RalfJung commented 8 months ago

The ICE is somewhere in resolve_drop_in_place... we're just calling that more often, but I don't think in any way that would be wrong? Not sure what's happening here.

Cc @oli-obk @compiler-errors

compiler-errors commented 8 months ago

Yeah there is a class of overflow errors that dont end up reporting errors but end up returning unconstrained infer vars, which end up escaping snapshots and causing explosions.

I don't have an example issue number, but I can find it when I'm at my desk.

compiler-errors commented 8 months ago

https://github.com/rust-lang/rust/issues/95134

compiler-errors commented 8 months ago

previous attempt to catch overflows in projection resulted in: https://github.com/rust-lang/rust/pull/104610

RalfJung commented 8 months ago

Ah so this is a stack overflow? I was already wondering why there is no overflow guard in this recursive call in the collector... In exchange there is an overflow guard in a non recursive call, and some special magic recursion limit handling I do not understand.

compiler-errors commented 8 months ago

This is not a stack overflow. This is an overflow in the trait solver, i.e. we've needed to compute a nested where clause that is too deep.

RalfJung commented 8 months ago

Ah okay. I don't think I understand why that would regress with my PR... In unoptimized builds it should do the same kind of trait resolutions as before. Strange.