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

Panic compiling multiplex-rs #46744

Closed
eira-fransham opened this issue Dec 15, 2017 · 3 comments · Fixed by #76256
Closed

Panic compiling multiplex-rs #46744

eira-fransham opened this issue Dec 15, 2017 · 3 comments · Fixed by #76256
Labels
A-incr-comp Area: Incremental compilation 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

@eira-fransham
Copy link

Index out of bounds ICE while compiling multiplex-rs. I don't know enough about why this could happen to produce a minimal reproduction. Backtrace:

thread 'rustc' panicked at 'index out of bounds: the len is 136 but the index is 146', /checkout/src/liballoc/vec.rs:1548:10
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at /checkout/src/libstd/sys_common/backtrace.rs:68
             at /checkout/src/libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:538
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:522
   7: rust_begin_unwind
             at /checkout/src/libstd/panicking.rs:498
   8: core::panicking::panic_fmt
             at /checkout/src/libcore/panicking.rs:71
   9: core::panicking::panic_bounds_check
             at /checkout/src/libcore/panicking.rs:58
  10: <rustc::ty::maps::on_disk_cache::CacheDecoder<'a, 'tcx, 'x> as serialize::serialize::SpecializedDecoder<syntax_pos::span_encoding::Span>>::specialized_decode
  11: serialize::serialize::Decoder::read_struct
  12: serialize::serialize::Decoder::read_struct
  13: serialize::serialize::Decoder::read_struct
  14: serialize::serialize::Decoder::read_seq
  15: <rustc::mir::Mir<'tcx> as serialize::serialize::Decodable>::decode::{{closure}}
  16: rustc::ty::maps::on_disk_cache::OnDiskCache::try_load_query_result
  17: rustc::ty::maps::<impl rustc::ty::maps::queries::optimized_mir<'tcx>>::try_get
  18: rustc::ty::maps::TyCtxtAt::optimized_mir
  19: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::optimized_mir
  20: rustc_metadata::encoder::<impl rustc_metadata::isolated_encoder::IsolatedEncoder<'a, 'b, 'tcx>>::encode_optimized_mir
  21: rustc_metadata::encoder::<impl rustc_metadata::isolated_encoder::IsolatedEncoder<'a, 'b, 'tcx>>::encode_info_for_impl_item
  22: rustc_metadata::encoder::<impl rustc_metadata::index_builder::IndexBuilder<'a, 'b, 'tcx>>::encode_addl_info_for_item
  23: rustc::hir::Crate::visit_all_item_likes
  24: rustc_metadata::encoder::encode_metadata
  25: rustc_metadata::cstore_impl::<impl rustc::middle::cstore::CrateStore for rustc_metadata::cstore::CStore>::encode_metadata
  26: rustc::ty::context::TyCtxt::encode_metadata
  27: rustc_trans::base::write_metadata
  28: rustc::util::common::time
  29: rustc_trans::base::trans_crate
  30: <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate
  31: rustc_driver::driver::phase_4_translate_to_llvm
  32: rustc_driver::driver::compile_input::{{closure}}
  33: <std::thread::local::LocalKey<T>>::with
  34: <std::thread::local::LocalKey<T>>::with
  35: rustc::ty::context::TyCtxt::create_and_enter
  36: rustc_driver::driver::compile_input
  37: rustc_driver::run_compiler
@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Dec 15, 2017
@estebank estebank added the A-incr-comp Area: Incremental compilation label Dec 17, 2017
@XAMPPRocky XAMPPRocky added the C-bug Category: This is a bug. label Mar 26, 2018
@aep
Copy link

aep commented Jun 23, 2018

here's a test case. i got this ICE by random (un)luck and i can't remove any further code or it won't reproduce. at least it's a single file.

cannot reproduce with rustc, must be called from cargo.
Cargo toml has no dependencies tho

use std::io;

enum Tree {
    Leaf(
        Vec<u8>
    ),
    Branch(
        Vec<BlockRef>,
    ),
}

struct Block {
    tree: Tree
}

enum BlockRef {
    StoreRef(Vec<u8>),
    Memory(Block),
}


trait Blockstore {
    fn store(&mut self, block: Block) -> io::Result<Block>;
}

struct FilesystemStore {
}

impl FilesystemStore {
    pub fn open<P: AsRef<Path>>(path: P) -> Result<Self> {
        Ok(Self{})
    }
}

impl Blockstore for FilesystemStore {
    fn store(&mut self, block: Block) -> io::Result<Block> {
    }
}

fn main() {
    let some_file = include_bytes!("main.rs");
}

@aep
Copy link

aep commented Jun 23, 2018

at least i think its related, since its in CacheDecoder as well

stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:207
   3: std::panicking::default_hook
             at libstd/panicking.rs:223
   4: core::ops::function::Fn::call
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:403
   6: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:349
   7: rust_begin_unwind
             at libstd/panicking.rs:325
   8: core::panicking::panic_fmt
             at libcore/panicking.rs:72
   9: core::panicking::panic_bounds_check
             at libcore/panicking.rs:58
  10: <rustc::ty::maps::on_disk_cache::CacheDecoder<'a, 'tcx, 'x> as serialize::serialize::SpecializedDecoder<syntax_pos::span_encoding::Span>>::specialized_decode
  11: serialize::serialize::Decoder::read_struct
  12: rustc::ty::maps::on_disk_cache::OnDiskCache::try_load_query_result
  13: rustc::ty::maps::<impl rustc::ty::maps::queries::generics_of<'tcx>>::try_get
  14: rustc::ty::maps::TyCtxtAt::generics_of
  15: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::generics_of
  16: <rustc_typeck::collect::CollectItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_trait_item
  17: rustc::hir::Crate::visit_all_item_likes
  18: rustc::session::Session::track_errors
  19: rustc_typeck::check_crate
  20: <std::thread::local::LocalKey<T>>::with
  21: <std::thread::local::LocalKey<T>>::with
  22: rustc::ty::context::TyCtxt::create_and_enter
  23: rustc_driver::driver::compile_input
  24: rustc_driver::run_compiler_impl
  25: syntax::with_globals

@aep
Copy link

aep commented Jun 23, 2018

cannot reproduce after cargo clean, so attached is the entire project. linux x86_64 rustc 1.26.2 (594fb25 2018-06-01)

46744.zip

@pnkfelix pnkfelix added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 29, 2019
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 12, 2020
incr-comp: hash and serialize span end line/column

Hash both the length and the end location (line/column) of a span. If we
hash only the length, for example, then two otherwise equal spans with
different end locations will have the same hash. This can cause a
problem during incremental compilation wherein a previous result for a
query that depends on the end location of a span will be incorrectly
reused when the end location of the span it depends on has changed. A
similar analysis applies if some query depends specifically on the
length of the span, but we only hash the end location. So hash both.

Fix rust-lang#46744, fix rust-lang#59954, fix rust-lang#63161, fix rust-lang#73640, fix rust-lang#73967, fix rust-lang#74890, fix rust-lang#75900

---

See rust-lang#74890 for a more in-depth analysis.

I haven't thought about what other problems this root cause could be responsible for. Please let me know if anything springs to mind. I believe the issue has existed since the inception of incremental compilation.
@bors bors closed this as completed in b71e627 Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation 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

Successfully merging a pull request may close this issue.

6 participants