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 when instrument-coverage flag is set: 'assertion failed: self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()' #84159

Closed
savente93 opened this issue Apr 13, 2021 · 6 comments
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) 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

@savente93
Copy link

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.

@savente93 savente93 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 Apr 13, 2021
@jyn514 jyn514 changed the title Rustc panics during install when instrument-coverage flag is set ICE when instrument-coverage flag is set: 'assertion failed: self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()', compiler/rustc_span/src/lib.rs:1511:9 Apr 13, 2021
@jyn514 jyn514 changed the title ICE when instrument-coverage flag is set: 'assertion failed: self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()', compiler/rustc_span/src/lib.rs:1511:9 ICE when instrument-coverage flag is set: 'assertion failed: self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()' Apr 13, 2021
@jyn514 jyn514 added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Apr 13, 2021
@richkadel
Copy link
Contributor

@dvente -

I recently submitted a couple of changes related to this kind of ICE error, and the most recent change is now available in nightly: rustc 1.53.0-nightly (bb491ed23 2021-04-23)

Can you please check to see if the error addresses your issue? If not, can you provide a small example rust program that I can easily copy and build, that reproduces the issue?

Thanks!

@savente93
Copy link
Author

I've tried it and the issue persists on the newest nightly commit on my machine. Sadly I can't provide you with any rust code to reproduce it since I'm not actually trying to compile any code myself when this triggers. However, you should be able to reproduce the issue by running: cargo install cargo-kov && RUSTFLAGS="-Zinstrument-coverage" cargo install cargo-edit --force That's a minimal working example as far as I can tell. The process seems to fail during the compilation of toml_edit. I hope this helps

@richkadel
Copy link
Contributor

Well, as it turns out there is one more related ICE bug I just notice in the github issues. I've submitted a fix for review.

@richkadel
Copy link
Contributor

richkadel commented Apr 25, 2021

Thanks for trying it again. I'm hopeful this will be the last bug and fix related to incompatible spans.

#84532

@richkadel
Copy link
Contributor

@dvente - Just letting you know that last PR was merged a few days ago and should be in Rust nightly now. (You may need to add --force to rustup since rustfmt seems to be broken in nightly again.)

Let me know if this doesn't fix your problem. Thanks!

@savente93
Copy link
Author

I've tried it and the problem seems to be fixed! I'm managing to run kcov now without any problems, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) 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

No branches or pull requests

3 participants