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

Recent nightly started ICEing with "No counters provided the source_hash for used function" #98833

Closed
alex opened this issue Jul 3, 2022 · 12 comments · Fixed by #98868 or #99711
Closed
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) A-mir-opt-inlining Area: MIR inlining C-bug Category: This is a bug. P-critical Critical priority regression-untriaged Untriaged performance or correctness regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@alex
Copy link
Member

alex commented Jul 3, 2022

This can be seen here: https://github.com/pyca/cryptography/runs/7165695219?check_suite_focus=true

Running `rustc --crate-name cryptography_rust --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type cdylib --emit=dep-info,link -C opt-level=3 -C lto=thin --crate-type cdylib -C overflow-checks=on --cfg 'feature="default"' --cfg 'feature="extension-module"' -C metadata=34bb19b331b20af2 --out-dir /home/runner/work/cryptography/cryptography/src/rust/target/release/deps -L dependency=/home/runner/work/cryptography/cryptography/src/rust/target/release/deps --extern asn1=/home/runner/work/cryptography/cryptography/src/rust/target/release/deps/libasn1-5b30914c3eca7b28.rlib --extern chrono=/home/runner/work/cryptography/cryptography/src/rust/target/release/deps/libchrono-ffc9d6801354fd45.rlib --extern once_cell=/home/runner/work/cryptography/cryptography/src/rust/target/release/deps/libonce_cell-0e0945728073c72b.rlib --extern ouroboros=/home/runner/work/cryptography/cryptography/src/rust/target/release/deps/libouroboros-5e1a3c513f27c586.rlib --extern pem=/home/runner/work/cryptography/cryptography/src/rust/target/release/deps/libpem-6f7633cd9970b696.rlib --extern pyo3=/home/runner/work/cryptography/cryptography/src/rust/target/release/deps/libpyo3-56560276294129fc.rlib -Cinstrument-coverage`
  thread 'rustc' panicked at 'No counters provided the source_hash for used function: Instance { def: Item(WithOptConstParam { did: DefId(42:58 ~ once_cell[2993]::imp::{impl#4}::is_initialized), const_param_did: None }), substs: [asn1::Tlv] }', compiler/rustc_codegen_ssa/src/coverageinfo/map.rs:156:9
  stack backtrace:
     0:     0x7f3d426e3b20 - std::backtrace_rs::backtrace::libunwind::trace::h419808c895a1be3b
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
     1:     0x7f3d426e3b20 - std::backtrace_rs::backtrace::trace_unsynchronized::h4cd640051eb1546f
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
     2:     0x7f3d426e3b20 - std::sys_common::backtrace::_print_fmt::h6a643b487717d871
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/sys_common/backtrace.rs:66:5
     3:     0x7f3d426e3b20 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h84bab1c2a632e967
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/sys_common/backtrace.rs:45:22
     4:     0x7f3d4273c85c - core::fmt::write::h41252a77742ac576
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/core/src/fmt/mod.rs:1198:17
     5:     0x7f3d426d53c5 - std::io::Write::write_fmt::h68f35cff36a534dd
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/io/mod.rs:1672:15
     6:     0x7f3d426e6711 - std::sys_common::backtrace::_print::h82f0b1ac2501b6af
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/sys_common/backtrace.rs:48:5
     7:     0x7f3d426e6711 - std::sys_common::backtrace::print::h3dc7f0e84685b9ba
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/sys_common/backtrace.rs:35:9
     8:     0x7f3d426e6711 - std::panicking::default_hook::{{closure}}::h6ace3fe16ec6f7aa
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/panicking.rs:295:22
     9:     0x7f3d426e63e3 - std::panicking::default_hook::h77c1c7afb621e87c
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/panicking.rs:314:9
    10:     0x7f3d42f02824 - rustc_driver[e83335c4a38137f8]::DEFAULT_HOOK::{closure#0}::{closure#0}
    11:     0x7f3d426e6ee6 - std::panicking::rust_panic_with_hook::h4cc32db16e14054a
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/panicking.rs:702:17
    12:     0x7f3d426e6d37 - std::panicking::begin_panic_handler::{{closure}}::h402861fe76edfc4d
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/panicking.rs:588:13
    13:     0x7f3d426e3ff4 - std::sys_common::backtrace::__rust_end_short_backtrace::he555a3759268da10
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/sys_common/backtrace.rs:138:18
    14:     0x7f3d426e6a62 - rust_begin_unwind
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/panicking.rs:584:5
    15:     0x7f3d426ab8e3 - core::panicking::panic_fmt::hd3841d7ec8a5a967
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/core/src/panicking.rs:142:14
    16:     0x7f3d43a09ced - <rustc_codegen_ssa[8f83f5a95e7fa903]::coverageinfo::map::FunctionCoverage>::get_expressions_and_counter_regions
    17:     0x7f3d43029b5e - rustc_codegen_llvm[ddaab1b683620c95]::coverageinfo::mapgen::finalize
    18:     0x7f3d44291216 - rustc_codegen_llvm[ddaab1b683620c95]::base::compile_codegen_unit::module_codegen
    19:     0x7f3d450cc586 - <rustc_query_system[c868fe53e983a2f2]::dep_graph::graph::DepGraph<rustc_middle[a37307bbdd285edd]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[a37307bbdd285edd]::ty::context::TyCtxt, rustc_span[550c183cd1c0caaa]::symbol::Symbol, rustc_codegen_ssa[8f83f5a95e7fa903]::ModuleCodegen<rustc_codegen_llvm[ddaab1b683620c95]::ModuleLlvm>>
    20:     0x7f3d450fdcf9 - rustc_codegen_llvm[ddaab1b683620c95]::base::compile_codegen_unit
    21:     0x7f3d450cf719 - rustc_codegen_ssa[8f83f5a95e7fa903]::base::codegen_crate::<rustc_codegen_llvm[ddaab1b683620c95]::LlvmCodegenBackend>
    22:     0x7f3d4512a3ea - <rustc_codegen_llvm[ddaab1b683620c95]::LlvmCodegenBackend as rustc_codegen_ssa[8f83f5a95e7fa903]::traits::backend::CodegenBackend>::codegen_crate
    23:     0x7f3d45098727 - <rustc_session[16e8265f3bee680e]::session::Session>::time::<alloc[aede580a0175a08c]::boxed::Box<dyn core[303bee78761e0753]::any::Any>, rustc_interface[edbb2596f0660065]::passes::start_codegen::{closure#0}>
    24:     0x7f3d45085d40 - <rustc_interface[edbb2596f0660065]::passes::QueryContext>::enter::<<rustc_interface[edbb2596f0660065]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[303bee78761e0753]::result::Result<alloc[aede580a0175a08c]::boxed::Box<dyn core[303bee78761e0753]::any::Any>, rustc_errors[cf96977[925](https://github.com/pyca/cryptography/runs/7165695219?check_suite_focus=true#step:9:926)b9f0c]::ErrorGuaranteed>>
    25:     0x7f3d4508fa23 - <rustc_interface[edbb2596f0660065]::queries::Queries>::ongoing_codegen
    26:     0x7f3d450518e1 - <rustc_interface[edbb2596f0660065]::interface::Compiler>::enter::<rustc_driver[e83335c4a38137f8]::run_compiler::{closure#1}::{closure#2}, core[303bee78761e0753]::result::Result<core[303bee78761e0753]::option::Option<rustc_interface[edbb2596f0660065]::queries::Linker>, rustc_errors[cf96977925b9f0c]::ErrorGuaranteed>>
    27:     0x7f3d4504dab0 - rustc_span[550c183cd1c0caaa]::with_source_map::<core[303bee78761e0753]::result::Result<(), rustc_errors[cf96977925b9f0c]::ErrorGuaranteed>, rustc_interface[edbb2596f0660065]::interface::create_compiler_and_run<core[303bee78761e0753]::result::Result<(), rustc_errors[cf96977925b9f0c]::ErrorGuaranteed>, rustc_driver[e83335c4a38137f8]::run_compiler::{closure#1}>::{closure#1}>
    28:     0x7f3d450680f2 - rustc_interface[edbb2596f0660065]::interface::create_compiler_and_run::<core[303bee78761e0753]::result::Result<(), rustc_errors[cf96977925b9f0c]::ErrorGuaranteed>, rustc_driver[e83335c4a38137f8]::run_compiler::{closure#1}>
    29:     0x7f3d4504d2b2 - <scoped_tls[c1a1588d7c68db11]::ScopedKey<rustc_span[550c183cd1c0caaa]::SessionGlobals>>::set::<rustc_interface[edbb2596f0660065]::interface::run_compiler<core[303bee78761e0753]::result::Result<(), rustc_errors[cf96977925b9f0c]::ErrorGuaranteed>, rustc_driver[e83335c4a38137f8]::run_compiler::{closure#1}>::{closure#0}, core[303bee78761e0753]::result::Result<(), rustc_errors[cf96977925b9f0c]::ErrorGuaranteed>>
    30:     0x7f3d4504ffcf - std[a38b499b13c80ab0]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[edbb2596f0660065]::util::run_in_thread_pool_with_globals<rustc_interface[edbb2596f0660065]::interface::run_compiler<core[303bee78761e0753]::result::Result<(), rustc_errors[cf96977925b9f0c]::ErrorGuaranteed>, rustc_driver[e83335c4a38137f8]::run_compiler::{closure#1}>::{closure#0}, core[303bee78761e0753]::result::Result<(), rustc_errors[cf96977925b9f0c]::ErrorGuaranteed>>::{closure#0}, core[303bee78761e0753]::result::Result<(), rustc_errors[cf96977925b9f0c]::ErrorGuaranteed>>
    31:     0x7f3d45068539 - <<std[a38b499b13c80ab0]::thread::Builder>::spawn_unchecked_<rustc_interface[edbb2596f0660065]::util::run_in_thread_pool_with_globals<rustc_interface[edbb2596f0660065]::interface::run_compiler<core[303bee78761e0753]::result::Result<(), rustc_errors[cf96977925b9f0c]::ErrorGuaranteed>, rustc_driver[e83335c4a38137f8]::run_compiler::{closure#1}>::{closure#0}, core[303bee78761e0753]::result::Result<(), rustc_errors[cf96977925b9f0c]::ErrorGuaranteed>>::{closure#0}, core[303bee78761e0753]::result::Result<(), rustc_errors[cf96977925b9f0c]::ErrorGuaranteed>>::{closure#1} as core[303bee78761e0753]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
    32:     0x7f3d426f0843 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6cafef397152c3f0
                                 at /rustc/f2d93[935](https://github.com/pyca/cryptography/runs/7165695219?check_suite_focus=true#step:9:936)ffba3ab9d7ccb5300771a2d29b4c8bf3/library/alloc/src/boxed.rs:1951:9
    33:     0x7f3d426f0843 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0308246411b63a3b
                                 at /rustc/f2d[939](https://github.com/pyca/cryptography/runs/7165695219?check_suite_focus=true#step:9:940)35ffba3ab9d7ccb5300771a2d29b4c8bf3/library/alloc/src/boxed.rs:1[951](https://github.com/pyca/cryptography/runs/7165695219?check_suite_focus=true#step:9:952):9
    34:     0x7f3d426f0843 - std::sys::unix::thread::Thread::new::thread_start::hd2e6d604897dcfa7
                                 at /rustc/f2d93935ffba3ab9d7ccb5300771a2d29b4c8bf3/library/std/src/sys/unix/thread.rs:108:17
    35:     0x7f3d42608609 - start_thread
    36:     0x7f3d4252b133 - clone
    37:                0x0 - <unknown>
  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.64.0-nightly (f2d93935f 2022-07-02) running on x86_64-unknown-linux-gnu
  note: compiler flags: --crate-type cdylib -C opt-level=3 -C lto=thin --crate-type cdylib -C overflow-checks=on -C instrument-coverage
  note: some of the compiler flags provided by cargo are hidden

To reproduce:

$ git clone https://github.com/pyca/cryptography
$ cd cryptography
# Apply the change from https://github.com/pyca/cryptography/pull/7387
$ vim tox.ini
$ RUSTUP_TOOLCHAIN=nightly RUSTFLAGS="-Cinstrument-coverage" tox -e rust -vvv
@alex alex added the C-bug Category: This is a bug. label Jul 3, 2022
@alex
Copy link
Member Author

alex commented Jul 3, 2022

Last passing run was nightly-x86_64-unknown-linux-gnu installed - rustc 1.64.0-nightly (7425fb293 2022-06-30) so this regressed between 2022-06-30 and 2022-07-02.

@alex
Copy link
Member Author

alex commented Jul 3, 2022

Minimized a reproducer.

Cargo.toml:

[package]
name = "z"
version = "0.1.0"
edition = "2021"

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

[dependencies]
once_cell = "1"
asn1 = { version = "0.9.1", default-features = false, features = ["derive"] }

src/lib.rs:

use once_cell::sync::Lazy;

pub static NULL_TLV: Lazy<asn1::Tlv<'static>> =
    Lazy::new(|| asn1::parse_single("\x05\x00").unwrap());

Execution:

$ RUSTFLAGS="-Cinstrument-coverage" cargo +nightly build --release
   Compiling num-integer v0.1.45
   Compiling chrono v0.4.19
thread 'rustc' panicked at 'No counters provided the source_hash for used function: Instance { def: Item(WithOptConstParam { did: DefId(0:53 ~ num_integer[ff7c]::roots::log2), const_param_did: None }), substs: [u128] }', compiler/rustc_codegen_ssa/src/coverageinfo/map.rs:156:9
stack backtrace:
   0:        0x1018dbf68 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha443feebef1054ca
   1:        0x101928698 - core::fmt::write::h326d27028239f921
   2:        0x1018ced1c - std::io::Write::write_fmt::h2e4d7ac9e7b0a445
   3:        0x1018de9e8 - std::panicking::default_hook::{{closure}}::hb60da310c8c45b08
   4:        0x1018de70c - std::panicking::default_hook::h7728ce77595813b9
   5:        0x108e40614 - rustc_driver[71d987a190a02667]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:        0x1018df0ac - std::panicking::rust_panic_with_hook::he11bb99bed5691b3
   7:        0x1018def54 - std::panicking::begin_panic_handler::{{closure}}::h15cc183105a01e55
   8:        0x1018dc46c - std::sys_common::backtrace::__rust_end_short_backtrace::h2e03eb47752209e1
   9:        0x1018decac - _rust_begin_unwind
  10:        0x101953930 - core::panicking::panic_fmt::h14b6ee096d68264c
  11:        0x10c010fe4 - <rustc_codegen_ssa[264ae2e5154ae899]::coverageinfo::map::FunctionCoverage>::get_expressions_and_counter_regions
  12:        0x10906c0f8 - rustc_codegen_llvm[e6b07e8dca291197]::coverageinfo::mapgen::finalize
  13:        0x10900872c - rustc_codegen_llvm[e6b07e8dca291197]::base::compile_codegen_unit::module_codegen
  14:        0x108f9cd34 - <rustc_query_system[24210b10db0c4feb]::dep_graph::graph::DepGraph<rustc_middle[fcca612a70a3d256]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[fcca612a70a3d256]::ty::context::TyCtxt, rustc_span[3feaa12df53193d3]::symbol::Symbol, rustc_codegen_ssa[264ae2e5154ae899]::ModuleCodegen<rustc_codegen_llvm[e6b07e8dca291197]::ModuleLlvm>>
  15:        0x109007e38 - rustc_codegen_llvm[e6b07e8dca291197]::base::compile_codegen_unit
  16:        0x108fa0204 - rustc_codegen_ssa[264ae2e5154ae899]::base::codegen_crate::<rustc_codegen_llvm[e6b07e8dca291197]::LlvmCodegenBackend>
  17:        0x10906e938 - <rustc_codegen_llvm[e6b07e8dca291197]::LlvmCodegenBackend as rustc_codegen_ssa[264ae2e5154ae899]::traits::backend::CodegenBackend>::codegen_crate
  18:        0x108ee743c - <rustc_session[bab2e65aebcec4dc]::session::Session>::time::<alloc[bc27fb785c4b0855]::boxed::Box<dyn core[666029bfe11acc21]::any::Any>, rustc_interface[b724eb991156d0f4]::passes::start_codegen::{closure#0}>
  19:        0x108ebfe38 - <rustc_interface[b724eb991156d0f4]::passes::QueryContext>::enter::<<rustc_interface[b724eb991156d0f4]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[666029bfe11acc21]::result::Result<alloc[bc27fb785c4b0855]::boxed::Box<dyn core[666029bfe11acc21]::any::Any>, rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>>
  20:        0x108edbcd0 - <rustc_interface[b724eb991156d0f4]::queries::Queries>::ongoing_codegen
  21:        0x108dd3c24 - <rustc_interface[b724eb991156d0f4]::interface::Compiler>::enter::<rustc_driver[71d987a190a02667]::run_compiler::{closure#1}::{closure#2}, core[666029bfe11acc21]::result::Result<core[666029bfe11acc21]::option::Option<rustc_interface[b724eb991156d0f4]::queries::Linker>, rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>>
  22:        0x108dcaf00 - rustc_span[3feaa12df53193d3]::with_source_map::<core[666029bfe11acc21]::result::Result<(), rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>, rustc_interface[b724eb991156d0f4]::interface::create_compiler_and_run<core[666029bfe11acc21]::result::Result<(), rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>, rustc_driver[71d987a190a02667]::run_compiler::{closure#1}>::{closure#1}>
  23:        0x108dee1bc - rustc_interface[b724eb991156d0f4]::interface::create_compiler_and_run::<core[666029bfe11acc21]::result::Result<(), rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>, rustc_driver[71d987a190a02667]::run_compiler::{closure#1}>
  24:        0x108dc7ea8 - <scoped_tls[d5a79b7ec1ef2205]::ScopedKey<rustc_span[3feaa12df53193d3]::SessionGlobals>>::set::<rustc_interface[b724eb991156d0f4]::interface::run_compiler<core[666029bfe11acc21]::result::Result<(), rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>, rustc_driver[71d987a190a02667]::run_compiler::{closure#1}>::{closure#0}, core[666029bfe11acc21]::result::Result<(), rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>>
  25:        0x108dd0bd8 - std[6562109629247121]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b724eb991156d0f4]::util::run_in_thread_pool_with_globals<rustc_interface[b724eb991156d0f4]::interface::run_compiler<core[666029bfe11acc21]::result::Result<(), rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>, rustc_driver[71d987a190a02667]::run_compiler::{closure#1}>::{closure#0}, core[666029bfe11acc21]::result::Result<(), rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>>::{closure#0}, core[666029bfe11acc21]::result::Result<(), rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>>
  26:        0x108e024ec - <<std[6562109629247121]::thread::Builder>::spawn_unchecked_<rustc_interface[b724eb991156d0f4]::util::run_in_thread_pool_with_globals<rustc_interface[b724eb991156d0f4]::interface::run_compiler<core[666029bfe11acc21]::result::Result<(), rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>, rustc_driver[71d987a190a02667]::run_compiler::{closure#1}>::{closure#0}, core[666029bfe11acc21]::result::Result<(), rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>>::{closure#0}, core[666029bfe11acc21]::result::Result<(), rustc_errors[2b5a7313142c52d3]::ErrorGuaranteed>>::{closure#1} as core[666029bfe11acc21]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:        0x1018e7184 - std::sys::unix::thread::Thread::new::thread_start::h00b5207c93c970dd
  28:        0x1ba22826c - __pthread_deallocate

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.64.0-nightly (f2d93935f 2022-07-02) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C instrument-coverage

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `num-integer`
warning: build failed, waiting for other jobs to finish...

@Rageking8
Copy link
Contributor

@rustbot label regression-untriaged

@rustbot rustbot added regression-untriaged Untriaged performance or correctness regression. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 3, 2022
@tmiasko tmiasko added A-mir-opt-inlining Area: MIR inlining A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) labels Jul 3, 2022
@5225225
Copy link
Contributor

5225225 commented Jul 3, 2022

Bisection says

searched nightlies: from nightly-2022-06-29 to nightly-2022-07-03
regressed nightly: nightly-2022-07-03
searched commit range: 46b8c23...f2d9393
regressed commit: 0075bb4

bisected with cargo-bisect-rustc v0.6.1

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start 2022-06-29 --regress ice -- build --release 

So, #91743

@apiraino
Copy link
Contributor

apiraino commented Jul 4, 2022

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-critical

@rustbot rustbot added P-critical Critical priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 4, 2022
kezhuw added a commit to kezhuw/zookeeper-client-rust that referenced this issue Jul 10, 2022
kezhuw added a commit to kezhuw/zookeeper-client-rust that referenced this issue Jul 10, 2022
kezhuw added a commit to kezhuw/zookeeper-client-rust that referenced this issue Jul 10, 2022
@tmiasko tmiasko removed their assignment Jul 11, 2022
@tmiasko tmiasko added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 14, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jul 21, 2022
…leywiser

Fix unreachable coverage generation for inlined functions

To generate a function coverage we need at least one coverage counter,
so a coverage from unreachable blocks is retained only when some live
counters remain.

The previous implementation incorrectly retained unreachable coverage,
because it didn't account for the fact that those live counters can
belong to another function due to inlining.

Fixes rust-lang#98833.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jul 22, 2022
…leywiser

Fix unreachable coverage generation for inlined functions

To generate a function coverage we need at least one coverage counter,
so a coverage from unreachable blocks is retained only when some live
counters remain.

The previous implementation incorrectly retained unreachable coverage,
because it didn't account for the fact that those live counters can
belong to another function due to inlining.

Fixes rust-lang#98833.
@bors bors closed this as completed in 6e3dd69 Jul 22, 2022
@alex
Copy link
Member Author

alex commented Jul 23, 2022

@tmiasko Unfortunately while this fixes the minimal reproducer, it doesn't fix the full case. Would you prefer I file a new bug, or should this one be re-opened?

To reproduce:

$ git clone https://github.com/pyca/cryptography
$ cd cryptography/src/rust/
$ RUSTFLAGS="-Cinstrument-coverage" cargo +nightly build --release
   Compiling pyo3 v0.15.2
thread 'rustc' panicked at 'No counters provided the source_hash for used function: Instance { def: Item(WithOptConstParam { did: DefId(0:6218 ~ pyo3[f11a]::python::{impl#6}::run::{closure#0}), const_param_did: None }), substs: [ReErased, i32, extern "rust-call" fn((&types::any::PyAny,)), ()] }', compiler/rustc_codegen_ssa/src/coverageinfo/map.rs:156:9
stack backtrace:
   0:     0x7f2b03aa28a0 - std::backtrace_rs::backtrace::libunwind::trace::h9ae2a0a86525a721
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f2b03aa28a0 - std::backtrace_rs::backtrace::trace_unsynchronized::h2db65d70ea604a8b
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f2b03aa28a0 - std::sys_common::backtrace::_print_fmt::ha87108be4ced4d7b
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f2b03aa28a0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8289c789e2444f52
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f2b03afbe7c - core::fmt::write::h4bc61850e148256a
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/core/src/fmt/mod.rs:1198:17
   5:     0x7f2b03a93ea5 - std::io::Write::write_fmt::h39fafbe9deae7dce
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/io/mod.rs:1672:15
   6:     0x7f2b03aa5531 - std::sys_common::backtrace::_print::h48b22fe50876db47
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f2b03aa5531 - std::sys_common::backtrace::print::h4deb0c8c0ba6e812
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f2b03aa5531 - std::panicking::default_hook::{{closure}}::hec18832ee0d2183c
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/panicking.rs:295:22
   9:     0x7f2b03aa5203 - std::panicking::default_hook::h6fd5dc4e9c4f675e
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/panicking.rs:314:9
  10:     0x7f2b04351af1 - rustc_driver[c212bfd01fb1bd4e]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f2b03aa5d06 - std::panicking::rust_panic_with_hook::hb4a45181e5abcce3
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/panicking.rs:702:17
  12:     0x7f2b03aa5b57 - std::panicking::begin_panic_handler::{{closure}}::h8b4f06c0b51d9e35
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/panicking.rs:588:13
  13:     0x7f2b03aa2d84 - std::sys_common::backtrace::__rust_end_short_backtrace::hc81506ddb6f68297
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f2b03aa5882 - rust_begin_unwind
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/panicking.rs:584:5
  15:     0x7f2b03a69b23 - core::panicking::panic_fmt::h16a5c315f7ebffa5
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/core/src/panicking.rs:142:14
  16:     0x7f2b04e8199a - <rustc_codegen_ssa[4eadd18c013d620f]::coverageinfo::map::FunctionCoverage>::get_expressions_and_counter_regions
  17:     0x7f2b04479338 - rustc_codegen_llvm[1092e7de2567b279]::coverageinfo::mapgen::finalize
  18:     0x7f2b056d393e - rustc_codegen_llvm[1092e7de2567b279]::base::compile_codegen_unit::module_codegen
  19:     0x7f2b06577049 - <rustc_query_system[606dbbc21d5be994]::dep_graph::graph::DepGraph<rustc_middle[339c612205d209e0]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[339c612205d209e0]::ty::context::TyCtxt, rustc_span[bd4aa58f7c6f9add]::symbol::Symbol, rustc_codegen_ssa[4eadd18c013d620f]::ModuleCodegen<rustc_codegen_llvm[1092e7de2567b279]::ModuleLlvm>>
  20:     0x7f2b065a6229 - rustc_codegen_llvm[1092e7de2567b279]::base::compile_codegen_unit
  21:     0x7f2b0657a3b9 - rustc_codegen_ssa[4eadd18c013d620f]::base::codegen_crate::<rustc_codegen_llvm[1092e7de2567b279]::LlvmCodegenBackend>
  22:     0x7f2b065bd291 - <rustc_codegen_llvm[1092e7de2567b279]::LlvmCodegenBackend as rustc_codegen_ssa[4eadd18c013d620f]::traits::backend::CodegenBackend>::codegen_crate
  23:     0x7f2b0653ede7 - <rustc_session[7be89286315efa93]::session::Session>::time::<alloc[2307dd647311a06c]::boxed::Box<dyn core[c7b8860b6e72b2f6]::any::Any>, rustc_interface[e455626695b2bf4c]::passes::start_codegen::{closure#0}>
  24:     0x7f2b0653b773 - <rustc_interface[e455626695b2bf4c]::passes::QueryContext>::enter::<<rustc_interface[e455626695b2bf4c]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[c7b8860b6e72b2f6]::result::Result<alloc[2307dd647311a06c]::boxed::Box<dyn core[c7b8860b6e72b2f6]::any::Any>, rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>
  25:     0x7f2b06531c83 - <rustc_interface[e455626695b2bf4c]::queries::Queries>::ongoing_codegen
  26:     0x7f2b064f9611 - <rustc_interface[e455626695b2bf4c]::interface::Compiler>::enter::<rustc_driver[c212bfd01fb1bd4e]::run_compiler::{closure#1}::{closure#2}, core[c7b8860b6e72b2f6]::result::Result<core[c7b8860b6e72b2f6]::option::Option<rustc_interface[e455626695b2bf4c]::queries::Linker>, rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>
  27:     0x7f2b064f579f - rustc_span[bd4aa58f7c6f9add]::with_source_map::<core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>, rustc_interface[e455626695b2bf4c]::interface::create_compiler_and_run<core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>, rustc_driver[c212bfd01fb1bd4e]::run_compiler::{closure#1}>::{closure#1}>
  28:     0x7f2b06511e50 - rustc_interface[e455626695b2bf4c]::interface::create_compiler_and_run::<core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>, rustc_driver[c212bfd01fb1bd4e]::run_compiler::{closure#1}>
  29:     0x7f2b06525e22 - <scoped_tls[ae38fa8e7a890916]::ScopedKey<rustc_span[bd4aa58f7c6f9add]::SessionGlobals>>::set::<rustc_interface[e455626695b2bf4c]::interface::run_compiler<core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>, rustc_driver[c212bfd01fb1bd4e]::run_compiler::{closure#1}>::{closure#0}, core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>
  30:     0x7f2b064f7cef - std[c85d7afaac2a6227]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e455626695b2bf4c]::util::run_in_thread_pool_with_globals<rustc_interface[e455626695b2bf4c]::interface::run_compiler<core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>, rustc_driver[c212bfd01fb1bd4e]::run_compiler::{closure#1}>::{closure#0}, core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>::{closure#0}, core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>
  31:     0x7f2b065122a9 - <<std[c85d7afaac2a6227]::thread::Builder>::spawn_unchecked_<rustc_interface[e455626695b2bf4c]::util::run_in_thread_pool_with_globals<rustc_interface[e455626695b2bf4c]::interface::run_compiler<core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>, rustc_driver[c212bfd01fb1bd4e]::run_compiler::{closure#1}>::{closure#0}, core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>::{closure#0}, core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>::{closure#1} as core[c7b8860b6e72b2f6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f2b03aaf753 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h713f45ba125dd07b
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/alloc/src/boxed.rs:1935:9
  33:     0x7f2b03aaf753 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5469f4a0b2b35b34
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/alloc/src/boxed.rs:1935:9
  34:     0x7f2b03aaf753 - std::sys::unix::thread::Thread::new::thread_start::h81d52548323558fa
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/sys/unix/thread.rs:108:17
  35:     0x7f2b0386cb43 - start_thread
                               at ./nptl/./nptl/pthread_create.c:442:8
  36:     0x7f2b038fea00 - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  37:                0x0 - <unknown>

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.64.0-nightly (848090dcd 2022-07-22) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C opt-level=3 -C linker-plugin-lto -C overflow-checks=on -C instrument-coverage

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `pyo3`

@alex
Copy link
Member Author

alex commented Jul 23, 2022

It's not very minimized, but slightly better.

RUSTFLAGS="-Cinstrument-coverage" cargo +nightly build --release

Cargo.toml:

[package]
name = "z"
version = "0.1.0"
edition = "2021"

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

[dependencies]
pyo3 = { version = "0.15.2" }

src/lib.rs: Empty

@tmiasko tmiasko reopened this Jul 23, 2022
@tmiasko
Copy link
Contributor

tmiasko commented Jul 23, 2022

// -Cinstrument-coverage -Cdebug-assertions=off
fn main() {
    Some(Some(0)).map(|x| {
        debug_assert!(x.is_some())
    });
}

searched nightlies: from nightly-2022-07-07 to nightly-2022-07-22
regressed nightly: nightly-2022-07-09
searched commits: from 1517f5d to 06754d8
regressed commit: eba361a

@alex
Copy link
Member Author

alex commented Jul 23, 2022

Interesting, I had assumed based on the matching panic message that it'd have the same regressing commit.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jul 25, 2022
Remove reachable coverage without counters

Remove reachable coverage without counters to maintain invariant that
either there is no coverage at all or there is a live coverage counter
left that provides the function source hash.

The motivating example would be a following closure:

```rust
    let f = |x: bool| {
        debug_assert!(x);
    };
```

Which, with span changes from rust-lang#93967, with disabled debug assertions,
after the final CFG simplifications but before removal of dead blocks,
gives rise to MIR:

```rust
fn main::{closure#0}(_1: &[[email protected]:2:13: 2:22], _2: bool) -> () {
    debug x => _2;
    let mut _0: ();

    bb0: {
        Coverage::Expression(4294967295) = 1 - 2;
        return;
    }

    ...
}
```

Which also makes the initial instrumentation quite suspect, although
this pull request doesn't attempt to address that aspect directly.

Fixes rust-lang#98833.

r? `@wesleywiser` `@richkadel`
@bors bors closed this as completed in 3c1eef2 Jul 26, 2022
@alex
Copy link
Member Author

alex commented Jul 27, 2022

Happy to report that with the latest nightly we're back to green on nightly. Thanks much @tmiasko!

@catenacyber
Copy link

Thanks @tmiasko the first fix was enough for Suricata :-)

@samuelcolvin
Copy link

Thanks so much, pydantic-core has been pinned to 2022-07-01 but is not back on nightly.

kezhuw added a commit to kezhuw/zookeeper-client-rust that referenced this issue Feb 14, 2023
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) A-mir-opt-inlining Area: MIR inlining C-bug Category: This is a bug. P-critical Critical priority regression-untriaged Untriaged performance or correctness regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
8 participants