Skip to content

ICE when instrument-coverage flag is set: 'assertion failed: self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()' #84159

Closed
@savente93

Description

@savente93

Context

The issue that prompted me to make this bug report occurred when I was trying to install something. As such I've provided a Dockerfile that reproduces the panic, instead of rust code, I hope that is also okay. I had been experimenting with cargo-kcov to measure test coverage for my new project, which I noticed that cargo add chrono didn't work. So I executed cargo install cargo-edit --force which produced the error. After some extra experimentation, I found out that it only happens if RUSTFLAGS="-Zinstrument-coverage" is set. Feel free to contact me if I've missed any relevant info.

Code [Dockerfile]

From rustlang/rust:nightly

WORKDIR /usr/src/
RUN cargo install cargo-kcov 

# the ENV RUSTFLAGS statement below is what causes the error
ENV RUSTFLAGS="-Zinstrument-coverage"
ENV RUST_BACKTRACTE=1

#Uncommenting RUN statement below will show the error
#RUN cargo install cargo-edit --force
CMD ["/bin/bash"]

Meta

[This is the meta from my own installation that caused the error originally, not from the docker, in case the docker image get's updated. again, hope this is okay]

rustc 1.53.0-nightly (d0695c908 2021-04-12)
binary: rustc
commit-hash: d0695c9081b16077d0aed368bccaf437d77ff497
commit-date: 2021-04-12
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

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.53.0-nightly (d0695c908 2021-04-12) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z instrument-coverage -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_promoted] processing `parser::array::array`
#1 [mir_borrowck] borrow-checking `parser::array::array`
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `toml_edit`

Backtrace

> RUST_BACKTRACE=1 cargo install cargo-edit --force
thread 'rustc' panicked at 'assertion failed: self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()', compiler/rustc_span/src/lib.rs:1511:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d0695c9081b16077d0aed368bccaf437d77ff497/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/d0695c9081b16077d0aed368bccaf437d77ff497/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/d0695c9081b16077d0aed368bccaf437d77ff497/library/core/src/panicking.rs:50:5
   3: rustc_span::SourceFile::lookup_file_pos
   4: rustc_mir::transform::coverage::Instrumentor::inject_counters
   5: <rustc_mir::transform::coverage::InstrumentCoverage as rustc_mir::transform::MirPass>::run_pass
   6: rustc_mir::transform::run_passes
   7: rustc_mir::transform::mir_promoted
   8: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
   9: rustc_data_structures::stack::ensure_sufficient_stack
  10: rustc_query_system::query::plumbing::force_query_with_job
  11: rustc_query_system::query::plumbing::get_query_impl
  12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_promoted
  13: rustc_mir::borrow_check::mir_borrowck
  14: core::ops::function::FnOnce::call_once
  15: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  16: rustc_data_structures::stack::ensure_sufficient_stack
  17: rustc_query_system::query::plumbing::force_query_with_job
  18: rustc_query_system::query::plumbing::get_query_impl
  19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  20: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  21: rustc_interface::passes::analysis
  22: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  23: rustc_data_structures::stack::ensure_sufficient_stack
  24: rustc_query_system::query::plumbing::force_query_with_job
  25: rustc_query_system::query::plumbing::get_query_impl
  26: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  27: rustc_interface::passes::QueryContext::enter
  28: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  29: rustc_span::with_source_map
  30: rustc_interface::interface::create_compiler_and_run
  31: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions