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

Nightly - -Zinstrument-coverage makes vendored openssl-sys cause a compiler panic #79725

Closed
xylix opened this issue Dec 5, 2020 · 4 comments · Fixed by #79818
Closed

Nightly - -Zinstrument-coverage makes vendored openssl-sys cause a compiler panic #79725

xylix opened this issue Dec 5, 2020 · 4 comments · Fixed by #79818
Assignees
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

@xylix
Copy link

xylix commented Dec 5, 2020

Code

Cargo.toml

[package]
name = "rust-nightly-05-12-repro"
version = "0.1.0"
authors = ["Kerkko Pelttari <kerk.pelt@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
openssl-sys = { version = "0.9.58", features = ["vendored"]}
RUSTFLAGS=-Zinstrument-coverage cargo test 

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (3ff10e74a 2020-12-04)
binary: rustc
commit-hash: 3ff10e74a74ed093fcabac1de27fe1cd65bbbb4a
commit-date: 2020-12-04
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

Error output

     Running `rustc --crate-name openssl_sys /home/xylix/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.58/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="openssl-src"' --cfg 'feature="vendored"' -C metadata=746b00652141f378 -C extra-filename=-746b00652141f378 --out-dir /home/xylix/Code/rust-nightly-05-12-repro/target/debug/deps -L dependency=/home/xylix/Code/rust-nightly-05-12-repro/target/debug/deps --extern libc=/home/xylix/Code/rust-nightly-05-12-repro/target/debug/deps/liblibc-e41c2d10207ee17e.rmeta --cap-lints allow -Zinstrument-coverage -L native=/home/xylix/Code/rust-nightly-05-12-repro/target/debug/build/openssl-sys-35bb66ffcf599d2f/out/openssl-build/install/lib --cfg const_fn --cfg 'osslconf="OPENSSL_NO_COMP"' --cfg 'osslconf="OPENSSL_NO_SSL3_METHOD"' --cfg ossl101 --cfg ossl102 --cfg ossl102f --cfg ossl102h --cfg ossl110 --cfg ossl110f --cfg ossl110g --cfg ossl110h --cfg ossl111 --cfg ossl111b --cfg ossl111c -l static=ssl -l static=crypto`
thread 'rustc' panicked at 'assertion failed: self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()', compiler/rustc_span/src/lib.rs:1495: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.50.0-nightly (3ff10e74a 2020-12-04) running on x86_64-unknown-linux-gnu

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 `err::ERR_PACK`
#1 [mir_borrowck] borrow-checking `err::ERR_PACK`
end of query stack
error: could not compile `openssl-sys`

Caused by:
  process didn't exit successfully: `rustc --crate-name openssl_sys /home/xylix/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.58/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="openssl-src"' --cfg 'feature="vendored"' -C metadata=746b00652141f378 -C extra-filename=-746b00652141f378 --out-dir /home/xylix/Code/rust-nightly-05-12-repro/target/debug/deps -L dependency=/home/xylix/Code/rust-nightly-05-12-repro/target/debug/deps --extern libc=/home/xylix/Code/rust-nightly-05-12-repro/target/debug/deps/liblibc-e41c2d10207ee17e.rmeta --cap-lints allow -Zinstrument-coverage -L native=/home/xylix/Code/rust-nightly-05-12-repro/target/debug/build/openssl-sys-35bb66ffcf599d2f/out/openssl-build/install/lib --cfg const_fn --cfg 'osslconf="OPENSSL_NO_COMP"' --cfg 'osslconf="OPENSSL_NO_SSL3_METHOD"' --cfg ossl101 --cfg ossl102 --cfg ossl102f --cfg ossl102h --cfg ossl110 --cfg ossl110f --cfg ossl110g --cfg ossl110h --cfg ossl111 --cfg ossl111b --cfg ossl111c -l static=ssl -l static=crypto` (exit code: 101)
Backtrace

 ~/C/rust-nightly-05-12-repro (master) [101]> RUST_BACKTRACE=1 RUSTFLAGS=-Zinstrument-coverage cargo build
   Compiling openssl-sys v0.9.58
thread 'rustc' panicked at 'assertion failed: self.start_pos.to_u32() + total_extra_bytes <= bpos.to_u32()', compiler/rustc_span/src/lib.rs:1495:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/3ff10e74a74ed093fcabac1de27fe1cd65bbbb4a/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/3ff10e74a74ed093fcabac1de27fe1cd65bbbb4a/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/3ff10e74a74ed093fcabac1de27fe1cd65bbbb4a/library/core/src/panicking.rs:50:5
   3: rustc_span::SourceFile::lookup_file_pos
   4: <rustc_mir::transform::coverage::InstrumentCoverage as rustc_mir::transform::MirPass>::run_pass
   5: rustc_mir::transform::run_passes
   6: rustc_mir::transform::mir_promoted
   7: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_promoted>::compute
   8: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
   9: rustc_query_system::query::plumbing::get_query_impl
  10: rustc_mir::borrow_check::mir_borrowck
  11: core::ops::function::FnOnce::call_once
  12: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute
  13: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  14: rustc_data_structures::stack::ensure_sufficient_stack
  15: rustc_query_system::query::plumbing::get_query_impl
  16: rustc_query_system::query::plumbing::ensure_query_impl
  17: rustc_session::utils::<impl rustc_session::session::Session>::time
  18: rustc_interface::passes::analysis
  19: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  20: rustc_query_system::dep_graph::graph::DepGraph<K>::with_eval_always_task
  21: rustc_data_structures::stack::ensure_sufficient_stack
  22: rustc_query_system::query::plumbing::get_query_impl
  23: rustc_interface::passes::QueryContext::enter
  24: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  25: rustc_span::with_source_map
  26: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.50.0-nightly (3ff10e74a 2020-12-04) running on x86_64-unknown-linux-gnu

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 `err::ERR_PACK`
#1 [mir_borrowck] borrow-checking `err::ERR_PACK`
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `openssl-sys`

To learn more, run the command again with --verbose.
 ~/C/rust-nightly-05-12-repro (master) [101]>

@xylix xylix 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 Dec 5, 2020
@nagisa nagisa added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Dec 6, 2020
@nagisa
Copy link
Member

nagisa commented Dec 6, 2020

cc @richkadel

@richkadel
Copy link
Contributor

Thanks for the bug report! I was able to repro this. Looking into the cause and fix now.

@camelid camelid added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Dec 7, 2020
@richkadel
Copy link
Contributor

Please try the fix in #79818 when available. Hopefully this will land in Rust nightly in just a few days.

Thanks again for reporting the bug!

tmandry added a commit to tmandry/rust that referenced this issue Dec 9, 2020
…1.0, r=tmandry

Fixes to Rust coverage

Fixes: rust-lang#79725

Some macros can create a situation where `fn_sig_span` and `body_span`
map to different files.

New documentation on coverage tests incorrectly assumed multiple test
binaries could just be listed at the end of the `llvm-cov` command,
but it turns out each binary needs a `--object` prefix.

This PR fixes the bug and updates the documentation to correct that
issue. It also fixes a few other minor issues in internal implementation
comments, and adds documentation on getting coverage results for doc
tests.
@bors bors closed this as completed in 95c268f Dec 10, 2020
@xylix
Copy link
Author

xylix commented Dec 11, 2020

Seems to work! Nice work.

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