Skip to content

Build with memory sanitizer causes panic #102730

Closed
@andreeaflorescu

Description

@andreeaflorescu

Code

This seems to happen when compiling rustc-std-workspace-core v1.99.0.
I am unsure what Rust code triggers this. I am running the following commands:

# git clone [email protected]:rust-vmm/vm-virtio.git
# cd vm-virtio/fuzz
cargo +nightly fuzz build --sanitizer memory

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (01af5040f 2022-10-04)
binary: rustc
commit-hash: 01af5040fdada6ef8f1b749cda798d80a8590b2c
commit-date: 2022-10-04
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2

I've tried the build with other nightly versions as well and it still fails but does not provide a stack trace.

Error output

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

cargo +nightly fuzz build --sanitizer memory 
   Compiling core v0.0.0 (/home/ubuntu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling rustc-std-workspace-core v1.99.0 (/home/ubuntu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_monomorphize/src/collector.rs:1379:36
stack backtrace:
   0:     0x7f10d7873450 - std::backtrace_rs::backtrace::libunwind::trace::h0940e595a024cae9
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f10d7873450 - std::backtrace_rs::backtrace::trace_unsynchronized::h105f21b55a45a169
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f10d7873450 - std::sys_common::backtrace::_print_fmt::h3a2ed111c2bd9337
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f10d7873450 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9029dd42bc5e75b6
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f10d78ce21e - core::fmt::write::he3e1f91c10d6c224
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f10d7863fd5 - std::io::Write::write_fmt::he1f986100980651d
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/io/mod.rs:1679:15
   6:     0x7f10d78761f3 - std::sys_common::backtrace::_print::h26c5f0fe9d048f5c
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f10d78761f3 - std::sys_common::backtrace::print::h9d099d945c0c1b8a
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f10d78761f3 - std::panicking::default_hook::{{closure}}::h56372a8ac9698e26
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/panicking.rs:267:22
   9:     0x7f10d7875eca - std::panicking::default_hook::h73cceb7588e9295f
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/panicking.rs:286:9
  10:     0x7f10da192801 - <rustc_driver[d216f18393925def]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[f28c5c09f5a57553]::ops::function::FnOnce<(&core[f28c5c09f5a57553]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f10d7876a2b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h0f73c471a795acd8
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/alloc/src/boxed.rs:1952:9
  12:     0x7f10d7876a2b - std::panicking::rust_panic_with_hook::hf37833f4792b3823
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/panicking.rs:673:13
  13:     0x7f10d7876841 - std::panicking::begin_panic_handler::{{closure}}::hc7fd5d2a7e5e3a2c
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/panicking.rs:558:13
  14:     0x7f10d78738fc - std::sys_common::backtrace::__rust_end_short_backtrace::hff4139a3352a2109
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/sys_common/backtrace.rs:138:18
  15:     0x7f10d78765a2 - rust_begin_unwind
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/panicking.rs:556:5
  16:     0x7f10d78cadf3 - core::panicking::panic_fmt::ha0d07fe43fc911c7
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/core/src/panicking.rs:142:14
  17:     0x7f10d78cac3d - core::panicking::panic::h3571a444b6e6cdf8
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/core/src/panicking.rs:48:5
  18:     0x7f10d98fff57 - rustc_monomorphize[6e58206baca4d005]::collector::collect_roots
  19:     0x7f10d98f6899 - <rustc_session[cacedf3acd9600ce]::session::Session>::time::<alloc[5d0ace609dc05d4e]::vec::Vec<rustc_middle[325b627bef73c729]::mir::mono::MonoItem>, rustc_monomorphize[6e58206baca4d005]::collector::collect_crate_mono_items::{closure#0}>
  20:     0x7f10d98f6661 - rustc_monomorphize[6e58206baca4d005]::collector::collect_crate_mono_items
  21:     0x7f10d98f5656 - rustc_monomorphize[6e58206baca4d005]::partitioning::collect_and_partition_mono_items
  22:     0x7f10d9ee9923 - rustc_query_system[559a9d93dbc3b734]::query::plumbing::try_execute_query::<rustc_query_impl[3e19586e51bce454]::plumbing::QueryCtxt, rustc_query_system[559a9d93dbc3b734]::query::caches::DefaultCache<(), (&std[69fb72ec8d4ef55]::collections::hash::set::HashSet<rustc_span[b945e457c1c57e62]::def_id::DefId, core[f28c5c09f5a57553]::hash::BuildHasherDefault<rustc_hash[b667fd82dee3cb6e]::FxHasher>>, &[rustc_middle[325b627bef73c729]::mir::mono::CodegenUnit])>>
  23:     0x7f10d9ee961b - rustc_query_system[559a9d93dbc3b734]::query::plumbing::get_query::<rustc_query_impl[3e19586e51bce454]::queries::collect_and_partition_mono_items, rustc_query_impl[3e19586e51bce454]::plumbing::QueryCtxt>
  24:     0x7f10d9ee955e - <rustc_query_impl[3e19586e51bce454]::Queries as rustc_middle[325b627bef73c729]::ty::query::QueryEngine>::collect_and_partition_mono_items
  25:     0x7f10d9c15a32 - rustc_codegen_ssa[a8334cec406dbdbb]::base::codegen_crate::<rustc_codegen_llvm[4eb5abec48d0068f]::LlvmCodegenBackend>
  26:     0x7f10d9c157fd - <rustc_codegen_llvm[4eb5abec48d0068f]::LlvmCodegenBackend as rustc_codegen_ssa[a8334cec406dbdbb]::traits::backend::CodegenBackend>::codegen_crate
  27:     0x7f10d8e7150c - <rustc_session[cacedf3acd9600ce]::session::Session>::time::<alloc[5d0ace609dc05d4e]::boxed::Box<dyn core[f28c5c09f5a57553]::any::Any>, rustc_interface[d1ba96d6460e1c37]::passes::start_codegen::{closure#0}>
  28:     0x7f10d8e70e2f - <rustc_interface[d1ba96d6460e1c37]::passes::QueryContext>::enter::<<rustc_interface[d1ba96d6460e1c37]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[f28c5c09f5a57553]::result::Result<alloc[5d0ace609dc05d4e]::boxed::Box<dyn core[f28c5c09f5a57553]::any::Any>, rustc_errors[b49a65fbc2f1496c]::ErrorGuaranteed>>
  29:     0x7f10d8e661c3 - <rustc_interface[d1ba96d6460e1c37]::queries::Queries>::ongoing_codegen
  30:     0x7f10d8e64488 - rustc_interface[d1ba96d6460e1c37]::interface::create_compiler_and_run::<core[f28c5c09f5a57553]::result::Result<(), rustc_errors[b49a65fbc2f1496c]::ErrorGuaranteed>, rustc_driver[d216f18393925def]::run_compiler::{closure#1}>
  31:     0x7f10d8e62d52 - <scoped_tls[b12dded96dfafbb1]::ScopedKey<rustc_span[b945e457c1c57e62]::SessionGlobals>>::set::<rustc_interface[d1ba96d6460e1c37]::interface::run_compiler<core[f28c5c09f5a57553]::result::Result<(), rustc_errors[b49a65fbc2f1496c]::ErrorGuaranteed>, rustc_driver[d216f18393925def]::run_compiler::{closure#1}>::{closure#0}, core[f28c5c09f5a57553]::result::Result<(), rustc_errors[b49a65fbc2f1496c]::ErrorGuaranteed>>
  32:     0x7f10d8e62a3f - std[69fb72ec8d4ef55]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d1ba96d6460e1c37]::util::run_in_thread_pool_with_globals<rustc_interface[d1ba96d6460e1c37]::interface::run_compiler<core[f28c5c09f5a57553]::result::Result<(), rustc_errors[b49a65fbc2f1496c]::ErrorGuaranteed>, rustc_driver[d216f18393925def]::run_compiler::{closure#1}>::{closure#0}, core[f28c5c09f5a57553]::result::Result<(), rustc_errors[b49a65fbc2f1496c]::ErrorGuaranteed>>::{closure#0}, core[f28c5c09f5a57553]::result::Result<(), rustc_errors[b49a65fbc2f1496c]::ErrorGuaranteed>>
  33:     0x7f10d9fa9890 - <<std[69fb72ec8d4ef55]::thread::Builder>::spawn_unchecked_<rustc_interface[d1ba96d6460e1c37]::util::run_in_thread_pool_with_globals<rustc_interface[d1ba96d6460e1c37]::interface::run_compiler<core[f28c5c09f5a57553]::result::Result<(), rustc_errors[b49a65fbc2f1496c]::ErrorGuaranteed>, rustc_driver[d216f18393925def]::run_compiler::{closure#1}>::{closure#0}, core[f28c5c09f5a57553]::result::Result<(), rustc_errors[b49a65fbc2f1496c]::ErrorGuaranteed>>::{closure#0}, core[f28c5c09f5a57553]::result::Result<(), rustc_errors[b49a65fbc2f1496c]::ErrorGuaranteed>>::{closure#1} as core[f28c5c09f5a57553]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7f10d7880503 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc84bda482f2a673d
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/alloc/src/boxed.rs:1938:9
  35:     0x7f10d7880503 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc8d281b5c9b3d170
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/alloc/src/boxed.rs:1938:9
  36:     0x7f10d7880503 - std::sys::unix::thread::Thread::new::thread_start::he8c81c74d5c82445
                               at /rustc/01af5040fdada6ef8f1b749cda798d80a8590b2c/library/std/src/sys/unix/thread.rs:108:17
  37:     0x7f10d774b609 - start_thread
  38:     0x7f10d766e163 - clone
  39:                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.66.0-nightly (01af5040f 2022-10-04) 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=memory -Z sanitizer-memory-track-origins -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.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleI-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