Skip to content

ICE: Option::unwrap() on a None value in check_attr.rs #109066

Closed
@langston-barrett

Description

@langston-barrett

This is a fuzzed test case, found with tree-splicer and minimized with treereduce. I hope it's valid, please let me know (and many apologies) if it's not helpful! I searched the issue tracker like so, and did not find any related issues. I was able to reproduce with a compiler I compiled from 7b4f489.

Code

#![doc(test(""))]

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (ff4b772f8 2023-03-10)
binary: rustc
commit-hash: ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13
commit-date: 2023-03-10
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_passes/src/check_attr.rs:971:57

Backtrace

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_passes/src/check_attr.rs:971:57
stack backtrace:
   0:     0x7efcc0ed451a - std::backtrace_rs::backtrace::libunwind::trace::hdf463920cb9883c6
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7efcc0ed451a - std::backtrace_rs::backtrace::trace_unsynchronized::hb1af812137cf3f3c
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7efcc0ed451a - std::sys_common::backtrace::_print_fmt::h6b1baa3b67580720
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7efcc0ed451a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2d9377ba074b9531
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7efcc0f37c5e - core::fmt::write::h852d00ad4ee2aeb3
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/core/src/fmt/mod.rs:1232:17
   5:     0x7efcc0ec74c5 - std::io::Write::write_fmt::hcea4b1a61e3aab77
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/io/mod.rs:1684:15
   6:     0x7efcc0ed42e5 - std::sys_common::backtrace::_print::hd824f24a945752af
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7efcc0ed42e5 - std::sys_common::backtrace::print::h8c438a1def0cf610
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7efcc0ed705f - std::panicking::default_hook::{{closure}}::hca9c2fb94ed37c32
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/panicking.rs:271:22
   9:     0x7efcc0ed6d9b - std::panicking::default_hook::h06237af56f487f7e
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/panicking.rs:290:9
  10:     0x7efcc4247935 - rustc_driver_impl[fadf77a465939c7e]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7efcc0ed789d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hd1c3deff0a8cf6e8
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/alloc/src/boxed.rs:2001:9
  12:     0x7efcc0ed789d - std::panicking::rust_panic_with_hook::h454607ef681fc36c
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/panicking.rs:696:13
  13:     0x7efcc0ed75d2 - std::panicking::begin_panic_handler::{{closure}}::hd799e1bbf586190b
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/panicking.rs:581:13
  14:     0x7efcc0ed4986 - std::sys_common::backtrace::__rust_end_short_backtrace::h99916aa65585462b
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/sys_common/backtrace.rs:150:18
  15:     0x7efcc0ed7322 - rust_begin_unwind
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/panicking.rs:579:5
  16:     0x7efcc0f33fb3 - core::panicking::panic_fmt::ha58db5c4260497c2
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/core/src/panicking.rs:64:14
  17:     0x7efcc0f3404d - core::panicking::panic::h0e014f1702a0cae1
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/core/src/panicking.rs:114:5
  18:     0x7efcc2a40124 - <rustc_passes[3d550cb493f825ed]::check_attr::CheckAttrVisitor>::check_attributes
  19:     0x7efcc2a3a456 - rustc_passes[3d550cb493f825ed]::check_attr::check_mod_attrs
  20:     0x7efcc386db25 - rustc_query_system[80421863a267aa4a]::query::plumbing::try_execute_query::<rustc_query_impl[66609fadc9a2c266]::queries::check_mod_attrs, rustc_query_impl[66609fadc9a2c266]::plumbing::QueryCtxt>
  21:     0x7efcc386d6ba - <rustc_query_impl[66609fadc9a2c266]::Queries as rustc_middle[d72fdf6c6b2250dd]::ty::query::QueryEngine>::check_mod_attrs
  22:     0x7efcc250852e - <core[3f771377e3383c20]::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures[7b438a47e12afbd2]::sync::par_for_each_in<&[rustc_hir[3b8935dc7f26c3f0]::hir_id::OwnerId], <rustc_middle[d72fdf6c6b2250dd]::hir::map::Map>::par_for_each_module<rustc_interface[5de5436d20c61019]::passes::analysis::{closure#0}::{closure#1}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}> as core[3f771377e3383c20]::ops::function::FnOnce<()>>::call_once
  23:     0x7efcc25083c8 - rustc_data_structures[7b438a47e12afbd2]::sync::par_for_each_in::<&[rustc_hir[3b8935dc7f26c3f0]::hir_id::OwnerId], <rustc_middle[d72fdf6c6b2250dd]::hir::map::Map>::par_for_each_module<rustc_interface[5de5436d20c61019]::passes::analysis::{closure#0}::{closure#1}::{closure#0}>::{closure#0}>
  24:     0x7efcc2508196 - <core[3f771377e3383c20]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[5de5436d20c61019]::passes::analysis::{closure#0}::{closure#1}> as core[3f771377e3383c20]::ops::function::FnOnce<()>>::call_once
  25:     0x7efcc2507e35 - <rustc_session[431311ff92ef7c59]::session::Session>::time::<(), rustc_interface[5de5436d20c61019]::passes::analysis::{closure#0}>
  26:     0x7efcc2506e28 - rustc_interface[5de5436d20c61019]::passes::analysis
  27:     0x7efcc3a54fbd - rustc_query_system[80421863a267aa4a]::query::plumbing::try_execute_query::<rustc_query_impl[66609fadc9a2c266]::queries::analysis, rustc_query_impl[66609fadc9a2c266]::plumbing::QueryCtxt>
  28:     0x7efcc3a54cbf - <rustc_query_impl[66609fadc9a2c266]::Queries as rustc_middle[d72fdf6c6b2250dd]::ty::query::QueryEngine>::analysis
  29:     0x7efcc386c8f6 - <rustc_middle[d72fdf6c6b2250dd]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[fadf77a465939c7e]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[3f771377e3383c20]::result::Result<(), rustc_span[36b4d2a6b64dd9a9]::ErrorGuaranteed>>
  30:     0x7efcc346e638 - rustc_span[36b4d2a6b64dd9a9]::with_source_map::<core[3f771377e3383c20]::result::Result<(), rustc_span[36b4d2a6b64dd9a9]::ErrorGuaranteed>, rustc_interface[5de5436d20c61019]::interface::run_compiler<core[3f771377e3383c20]::result::Result<(), rustc_span[36b4d2a6b64dd9a9]::ErrorGuaranteed>, rustc_driver_impl[fadf77a465939c7e]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  31:     0x7efcc3465b1c - std[b4a766eaf44c2ca8]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[5de5436d20c61019]::util::run_in_thread_pool_with_globals<rustc_interface[5de5436d20c61019]::interface::run_compiler<core[3f771377e3383c20]::result::Result<(), rustc_span[36b4d2a6b64dd9a9]::ErrorGuaranteed>, rustc_driver_impl[fadf77a465939c7e]::run_compiler::{closure#1}>::{closure#0}, core[3f771377e3383c20]::result::Result<(), rustc_span[36b4d2a6b64dd9a9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3f771377e3383c20]::result::Result<(), rustc_span[36b4d2a6b64dd9a9]::ErrorGuaranteed>>
  32:     0x7efcc346554a - <<std[b4a766eaf44c2ca8]::thread::Builder>::spawn_unchecked_<rustc_interface[5de5436d20c61019]::util::run_in_thread_pool_with_globals<rustc_interface[5de5436d20c61019]::interface::run_compiler<core[3f771377e3383c20]::result::Result<(), rustc_span[36b4d2a6b64dd9a9]::ErrorGuaranteed>, rustc_driver_impl[fadf77a465939c7e]::run_compiler::{closure#1}>::{closure#0}, core[3f771377e3383c20]::result::Result<(), rustc_span[36b4d2a6b64dd9a9]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3f771377e3383c20]::result::Result<(), rustc_span[36b4d2a6b64dd9a9]::ErrorGuaranteed>>::{closure#1} as core[3f771377e3383c20]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7efcc0ee1793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h302a99ca9b0b5ec7
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/alloc/src/boxed.rs:1987:9
  34:     0x7efcc0ee1793 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4a906cac1587b7da
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/alloc/src/boxed.rs:1987:9
  35:     0x7efcc0ee1793 - std::sys::unix::thread::Thread::new::thread_start::heb9513f4b22d271f
                               at /rustc/ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13/library/std/src/sys/unix/thread.rs:108:17
  36:     0x7efcc0c4bff2 - start_thread
  37:     0x7efcc0ccebfc - clone3
  38:                0x0 - <unknown>

error: 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.70.0-nightly (ff4b772f8 2023-03-10) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_mod_attrs] checking attributes in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0601`.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions