Skip to content

-Zbuild-std with cargo-fuzz causes: 'called Option::unwrap() on a None value', compiler/rustc_monomorphize/src/collector.rs #101930

Closed
@saethlin

Description

@saethlin

Code

cargo new scratch
cd scratch
cargo fuzz init
cargo +nightly fuzz build fuzz_target_1 -Zbuild-std --target=x86_64-unknown-linux-gnu

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (750bd1a7f 2022-09-14)
binary: rustc
commit-hash: 750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c
commit-date: 2022-09-14
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_monomorphize/src/collector.rs:1401:36
Backtrace

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_monomorphize/src/collector.rs:1401:36
stack backtrace:
   0:     0x7f06e096dc20 - std::backtrace_rs::backtrace::libunwind::trace::hf9cd4c385c25a2fe
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f06e096dc20 - std::backtrace_rs::backtrace::trace_unsynchronized::hf9a1be2df46de98c
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f06e096dc20 - std::sys_common::backtrace::_print_fmt::ha770a6c3890b3cde
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f06e096dc20 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7099a61d18d47f5f
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f06e09c8aee - core::fmt::write::h34c269a5556240be
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f06e095e835 - std::io::Write::write_fmt::h9b1d898decaac979
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/io/mod.rs:1679:15
   6:     0x7f06e09708d3 - std::sys_common::backtrace::_print::hb8325cbd910e0a42
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f06e09708d3 - std::sys_common::backtrace::print::h52eaf8f4259fb854
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f06e09708d3 - std::panicking::default_hook::{{closure}}::h38a1bd1ceb333281
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/panicking.rs:295:22
   9:     0x7f06e09705bf - std::panicking::default_hook::hbfa37b6c2aa83708
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/panicking.rs:314:9
  10:     0x7f06e31d7001 - <rustc_driver[f7b5b01335fbd434]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[f6f8d9be6066ab2c]::ops::function::FnOnce<(&core[f6f8d9be6066ab2c]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f06e097110d - std::panicking::rust_panic_with_hook::h6bfc21eea1a19790
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/panicking.rs:702:17
  12:     0x7f06e0970f21 - std::panicking::begin_panic_handler::{{closure}}::hb8d2ca3a2b559a99
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/panicking.rs:586:13
  13:     0x7f06e096e0cc - std::sys_common::backtrace::__rust_end_short_backtrace::h5cb05ed133585c86
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f06e0970c82 - rust_begin_unwind
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/panicking.rs:584:5
  15:     0x7f06e09c56c3 - core::panicking::panic_fmt::hee1e6e55422e6267
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/core/src/panicking.rs:142:14
  16:     0x7f06e09c550d - core::panicking::panic::hc24a3511099b040d
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/core/src/panicking.rs:48:5
  17:     0x7f06e2be6c0f - rustc_monomorphize[69d39ad0a252eef9]::collector::collect_roots
  18:     0x7f06e2bdc549 - <rustc_session[c3e5419825648902]::session::Session>::time::<alloc[9d62437589f31483]::vec::Vec<rustc_middle[af3205fb0fe14459]::mir::mono::MonoItem>, rustc_monomorphize[69d39ad0a252eef9]::collector::collect_crate_mono_items::{closure#0}>
  19:     0x7f06e2bdc311 - rustc_monomorphize[69d39ad0a252eef9]::collector::collect_crate_mono_items
  20:     0x7f06e2bdb2b6 - rustc_monomorphize[69d39ad0a252eef9]::partitioning::collect_and_partition_mono_items
  21:     0x7f06e2f79cdd - rustc_query_system[d9fae65d8b1eb5ad]::query::plumbing::try_execute_query::<rustc_query_impl[1a54d4e1bcc8b675]::plumbing::QueryCtxt, rustc_query_system[d9fae65d8b1eb5ad]::query::caches::DefaultCache<(), (&std[81ab5d9a96a0142e]::collections::hash::set::HashSet<rustc_span[352514dd70ceaa1d]::def_id::DefId, core[f6f8d9be6066ab2c]::hash::BuildHasherDefault<rustc_hash[7fe789eacc3442d8]::FxHasher>>, &[rustc_middle[af3205fb0fe14459]::mir::mono::CodegenUnit])>>
  22:     0x7f06e2f799bb - rustc_query_system[d9fae65d8b1eb5ad]::query::plumbing::get_query::<rustc_query_impl[1a54d4e1bcc8b675]::queries::collect_and_partition_mono_items, rustc_query_impl[1a54d4e1bcc8b675]::plumbing::QueryCtxt>
  23:     0x7f06e2f798fe - <rustc_query_impl[1a54d4e1bcc8b675]::Queries as rustc_middle[af3205fb0fe14459]::ty::query::QueryEngine>::collect_and_partition_mono_items
  24:     0x7f06e2cbed92 - rustc_codegen_ssa[ae1047109b7e1721]::base::codegen_crate::<rustc_codegen_llvm[2cfc2535e7c3b00c]::LlvmCodegenBackend>
  25:     0x7f06e2cbeb62 - <rustc_codegen_llvm[2cfc2535e7c3b00c]::LlvmCodegenBackend as rustc_codegen_ssa[ae1047109b7e1721]::traits::backend::CodegenBackend>::codegen_crate
  26:     0x7f06e2004efc - <rustc_session[c3e5419825648902]::session::Session>::time::<alloc[9d62437589f31483]::boxed::Box<dyn core[f6f8d9be6066ab2c]::any::Any>, rustc_interface[5bcac5cfb78c3b1a]::passes::start_codegen::{closure#0}>
  27:     0x7f06e20048ce - <rustc_interface[5bcac5cfb78c3b1a]::passes::QueryContext>::enter::<<rustc_interface[5bcac5cfb78c3b1a]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[f6f8d9be6066ab2c]::result::Result<alloc[9d62437589f31483]::boxed::Box<dyn core[f6f8d9be6066ab2c]::any::Any>, rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>>
  28:     0x7f06e1fc44b3 - <rustc_interface[5bcac5cfb78c3b1a]::queries::Queries>::ongoing_codegen
  29:     0x7f06e1fc290a - rustc_interface[5bcac5cfb78c3b1a]::interface::create_compiler_and_run::<core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>, rustc_driver[f7b5b01335fbd434]::run_compiler::{closure#1}>
  30:     0x7f06e1fc1211 - <scoped_tls[de48490ce358b7ec]::ScopedKey<rustc_span[352514dd70ceaa1d]::SessionGlobals>>::set::<rustc_interface[5bcac5cfb78c3b1a]::interface::run_compiler<core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>, rustc_driver[f7b5b01335fbd434]::run_compiler::{closure#1}>::{closure#0}, core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>>
  31:     0x7f06e1fc0eff - std[81ab5d9a96a0142e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[5bcac5cfb78c3b1a]::util::run_in_thread_pool_with_globals<rustc_interface[5bcac5cfb78c3b1a]::interface::run_compiler<core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>, rustc_driver[f7b5b01335fbd434]::run_compiler::{closure#1}>::{closure#0}, core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>>::{closure#0}, core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>>
  32:     0x7f06e303b000 - <<std[81ab5d9a96a0142e]::thread::Builder>::spawn_unchecked_<rustc_interface[5bcac5cfb78c3b1a]::util::run_in_thread_pool_with_globals<rustc_interface[5bcac5cfb78c3b1a]::interface::run_compiler<core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>, rustc_driver[f7b5b01335fbd434]::run_compiler::{closure#1}>::{closure#0}, core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>>::{closure#0}, core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>>::{closure#1} as core[f6f8d9be6066ab2c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7f06e097aee3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2695b43ebae659e4
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/alloc/src/boxed.rs:1940:9
  34:     0x7f06e097aee3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf3b49b955267341c
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/alloc/src/boxed.rs:1940:9
  35:     0x7f06e097aee3 - std::sys::unix::thread::Thread::new::thread_start::h2bad5ab8a769c6c8
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/sys/unix/thread.rs:108:17
  36:     0x7f06e071c74d - <unknown>
  37:     0x7f06e079e700 - <unknown>
  38:                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.65.0-nightly (750bd1a7f 2022-09-14) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -Z force-unstable-if-unmarked -C passes=sancov-module -C llvm-args=-sanitizer-coverage-level=4 -C llvm-args=-sanitizer-coverage-trace-compares -C llvm-args=-sanitizer-coverage-inline-8bit-counters -C llvm-args=-sanitizer-coverage-pc-table -C link-dead-code -Z sanitizer=address -C llvm-args=-sanitizer-coverage-stack-depth -C debug-assertions -C codegen-units=1

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

query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    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