Skip to content

Internal compiler error while running llvm-tools-preview #83792

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

Closed
epompeii opened this issue Apr 2, 2021 · 1 comment · Fixed by #84532
Closed

Internal compiler error while running llvm-tools-preview #83792

epompeii opened this issue Apr 2, 2021 · 1 comment · Fixed by #84532
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) 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

@epompeii
Copy link

epompeii commented Apr 2, 2021

Hey All,
I was trying to follow the instructions to run grcov, and things bottomed out on me.
The compiler suggested I open this issue so here I am!

It may be worth mentioning that I am in a Cargo Workspace, and I'm not using a Cargo.lock file.
The compiler error appears to go away when I remove cargo-edit as a dev dependency. Without it though, things seem to work just fine.

Going back to my larger project and removing cargo-edit also fixed things there.

Code

Cargo.toml

[package]
name = "mvp"
version = "0.1.0"
authors = ["epompeii"]
edition = "2018"

[dev-dependencies]
cargo-edit = "0.7"

lib.rs

pub fn hello() -> &'static str {
    "hello"
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    pub fn test_hello() {
        assert_eq!(hello(), "hello");
    }
}

I ran the following:

  • rustup override set nightly
  • rustup component add llvm-tools-preview
  • export RUSTFLAGS="-Zinstrument-coverage"
  • cargo clean
  • cargo build
  • cargo test

Meta

Output of rustc --version --verbose:

rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
binary: rustc
commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597
commit-date: 2021-03-24
host: x86_64-apple-darwin
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

The failure message:

thread 'rustc' panicked at 'assertion failed: self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()', compiler/rustc_span/src/lib.rs:1518:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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 (07e0e2ec2 2021-03-24) running on x86_64-apple-darwin

note: compiler flags: -Z instrument-coverage -C embed-bitcode=no -C debuginfo=2 --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`
end of query stack
error: could not compile `toml_edit`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
@epompeii epompeii 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 2, 2021
@jyn514 jyn514 added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Apr 2, 2021
@JohnTitor JohnTitor added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Apr 3, 2021
@richkadel
Copy link
Contributor

I can confirm this is still a problem, and I'm looking into it. I narrowed down the issue a little more, to compiling the toml_edit crate (version 0.2.0 at least). I don't think it matters what is in lib.rs in the example above. The compiler never gets there.

This simplified Cargo.toml also generates the error, on RUSTFLAGS="-Zinstrument-coverage" cargo build:

[package]
name = "issue_83792"
version = "0.0.1"
authors = ["richkadel"]
edition = "2018"

[dependencies]
toml_edit = "0.2.0"

bors added a commit to rust-lang-ci/rust that referenced this issue Apr 27, 2021
Fix coverage ICE because fn_sig can have a span that crosses file bou…

Fixes: rust-lang#83792

MIR `InstrumentCoverage` assumed the `FnSig` span was contained within a
single file, but this is not always the case. Some macro constructions
can result in a span that starts in one `SourceFile` and ends in a
different one.

The `FnSig` span is included in coverage results as long as that span is
in the same `SourceFile` and the same macro context, but by assuming the
`FnSig` span's `hi()` and `lo()` were in the same file, I took this for
granted, and checked only that the `FnSig` `hi()` was in the same
`SourceFile` as the `body_span`.

I actually drop the `hi()` though, and extend the `FnSig` span to the
`body_span.lo()`, so I really should have simply checked that the
`FnSig` span's `lo()` was in the `SourceFile` of the `body_span`.

r? `@tmandry`
cc: `@wesleywiser`
@bors bors closed this as completed in 31cba57 Apr 27, 2021
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. 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

Successfully merging a pull request may close this issue.

4 participants