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

ICE None privacy #121455

Closed
matthiaskrgr opened this issue Feb 22, 2024 · 1 comment · Fixed by #121482
Closed

ICE None privacy #121455

matthiaskrgr opened this issue Feb 22, 2024 · 1 comment · Fixed by #121482
Assignees
Labels
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.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

fn test(s: &Self::Id) {
    match &s[0..3] {}
}

fn main() {}

original:

fn test(s: &Self::Id) {
    match &s[0..3] {
        b"aba" => {}
        _ => {}
    }
}

fn main() {}

Version information

rustc 1.78.0-nightly (f70f19fef 2024-02-22)
binary: rustc
commit-hash: f70f19fef41cfdda75c92f163434c29ad046cf09
commit-date: 2024-02-22
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/gh-matthiaskrgr/.rustup/toolchains/master/bin/rustc

Program output

warning: function `test` is never used
 --> /tmp/icemaker_global_tempdir.Lv2nHaQbve2G/rustc_testrunner_tmpdir_reporting.1yfawIGP80kJ/mvce.rs:1:4
  |
1 | fn test(s: &Self::Id) {
  |    ^^^^
  |
  = note: `#[warn(dead_code)]` on by default

thread 'rustc' panicked at compiler/rustc_privacy/src/lib.rs:991:72:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7fe17104baf6 - std::backtrace_rs::backtrace::libunwind::trace::hef019eae7250a090
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fe17104baf6 - std::backtrace_rs::backtrace::trace_unsynchronized::h163c9c558e7f1e4e
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fe17104baf6 - std::sys_common::backtrace::_print_fmt::h84a7f2dbeae8e017
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fe17104baf6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf7737af35c1403cd
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fe17109ca7c - core::fmt::rt::Argument::fmt::h027f33016919ab54
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/core/src/fmt/rt.rs:142:9
   5:     0x7fe17109ca7c - core::fmt::write::hed9b631feef55974
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fe1710404bf - std::io::Write::write_fmt::h3b1c8483aebfcef8
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/io/mod.rs:1846:15
   7:     0x7fe17104b8a4 - std::sys_common::backtrace::_print::h526b95c0b60f4650
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fe17104b8a4 - std::sys_common::backtrace::print::h3322d8b0a1d6207a
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fe17104e5eb - std::panicking::default_hook::{{closure}}::h9f07e6147b1c8a2e
  10:     0x7fe17104e339 - std::panicking::default_hook::h395b386ace4fbcb6
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/panicking.rs:292:9
  11:     0x7fe16dc7073c - std[d26ecb90c771e100]::panicking::update_hook::<alloc[100d4e65626f4394]::boxed::Box<rustc_driver_impl[ab901dc85bea4c82]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fe17104ed50 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1a188bbe7a6bf646
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/alloc/src/boxed.rs:2030:9
  13:     0x7fe17104ed50 - std::panicking::rust_panic_with_hook::h1eec7c1097026ee4
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/panicking.rs:786:13
  14:     0x7fe17104ea59 - std::panicking::begin_panic_handler::{{closure}}::h4a05c0337f2d10b0
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/panicking.rs:652:13
  15:     0x7fe17104bfd6 - std::sys_common::backtrace::__rust_end_short_backtrace::h8e493856f2567f06
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7fe17104e7c4 - rust_begin_unwind
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/panicking.rs:648:5
  17:     0x7fe171098f95 - core::panicking::panic_fmt::h3ada378d4b3e4e06
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/core/src/panicking.rs:72:14
  18:     0x7fe171099053 - core::panicking::panic::hf686bd38e73a6fb0
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/core/src/panicking.rs:144:5
  19:     0x7fe171098d26 - core::option::unwrap_failed::hfcdeaccb62b77869
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/core/src/option.rs:1983:5
  20:     0x7fe16f06a5ff - <rustc_privacy[80d2fffb773ca6d2]::NamePrivacyVisitor as rustc_hir[c73f1de04e7d2c16]::intravisit::Visitor>::visit_expr
  21:     0x7fe16f069ae5 - <rustc_privacy[80d2fffb773ca6d2]::NamePrivacyVisitor as rustc_hir[c73f1de04e7d2c16]::intravisit::Visitor>::visit_expr
  22:     0x7fe16f0699a1 - <rustc_privacy[80d2fffb773ca6d2]::NamePrivacyVisitor as rustc_hir[c73f1de04e7d2c16]::intravisit::Visitor>::visit_expr
  23:     0x7fe16f069beb - <rustc_privacy[80d2fffb773ca6d2]::NamePrivacyVisitor as rustc_hir[c73f1de04e7d2c16]::intravisit::Visitor>::visit_expr
  24:     0x7fe16f0699e2 - <rustc_privacy[80d2fffb773ca6d2]::NamePrivacyVisitor as rustc_hir[c73f1de04e7d2c16]::intravisit::Visitor>::visit_expr
  25:     0x7fe16f733bce - rustc_privacy[80d2fffb773ca6d2]::check_mod_privacy
  26:     0x7fe16f7339ad - rustc_query_impl[9d2321c4f9b7ef6e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9d2321c4f9b7ef6e]::query_impl::check_mod_privacy::dynamic_query::{closure#2}::{closure#0}, rustc_middle[771c523b66a87e77]::query::erase::Erased<[u8; 0usize]>>
  27:     0x7fe16fba4cad - rustc_query_system[1927276894a91dd8]::query::plumbing::try_execute_query::<rustc_query_impl[9d2321c4f9b7ef6e]::DynamicConfig<rustc_query_system[1927276894a91dd8]::query::caches::DefaultCache<rustc_span[4d20b27f335b5d92]::def_id::LocalModDefId, rustc_middle[771c523b66a87e77]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[9d2321c4f9b7ef6e]::plumbing::QueryCtxt, false>
  28:     0x7fe16fba077f - rustc_query_impl[9d2321c4f9b7ef6e]::query_impl::check_mod_privacy::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7fe16fb9cb7c - rustc_interface[863afa250f767019]::passes::analysis
  30:     0x7fe16fb9b759 - rustc_query_impl[9d2321c4f9b7ef6e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9d2321c4f9b7ef6e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[771c523b66a87e77]::query::erase::Erased<[u8; 1usize]>>
  31:     0x7fe16fd45303 - rustc_query_system[1927276894a91dd8]::query::plumbing::try_execute_query::<rustc_query_impl[9d2321c4f9b7ef6e]::DynamicConfig<rustc_query_system[1927276894a91dd8]::query::caches::SingleCache<rustc_middle[771c523b66a87e77]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[9d2321c4f9b7ef6e]::plumbing::QueryCtxt, false>
  32:     0x7fe16fd4507f - rustc_query_impl[9d2321c4f9b7ef6e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7fe16fd54556 - rustc_interface[863afa250f767019]::interface::run_compiler::<core[17d6b7ce805ba05e]::result::Result<(), rustc_span[4d20b27f335b5d92]::ErrorGuaranteed>, rustc_driver_impl[ab901dc85bea4c82]::run_compiler::{closure#0}>::{closure#0}
  34:     0x7fe16ffbe305 - std[d26ecb90c771e100]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[863afa250f767019]::util::run_in_thread_with_globals<rustc_interface[863afa250f767019]::util::run_in_thread_pool_with_globals<rustc_interface[863afa250f767019]::interface::run_compiler<core[17d6b7ce805ba05e]::result::Result<(), rustc_span[4d20b27f335b5d92]::ErrorGuaranteed>, rustc_driver_impl[ab901dc85bea4c82]::run_compiler::{closure#0}>::{closure#0}, core[17d6b7ce805ba05e]::result::Result<(), rustc_span[4d20b27f335b5d92]::ErrorGuaranteed>>::{closure#0}, core[17d6b7ce805ba05e]::result::Result<(), rustc_span[4d20b27f335b5d92]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[17d6b7ce805ba05e]::result::Result<(), rustc_span[4d20b27f335b5d92]::ErrorGuaranteed>>
  35:     0x7fe16ffbe132 - <<std[d26ecb90c771e100]::thread::Builder>::spawn_unchecked_<rustc_interface[863afa250f767019]::util::run_in_thread_with_globals<rustc_interface[863afa250f767019]::util::run_in_thread_pool_with_globals<rustc_interface[863afa250f767019]::interface::run_compiler<core[17d6b7ce805ba05e]::result::Result<(), rustc_span[4d20b27f335b5d92]::ErrorGuaranteed>, rustc_driver_impl[ab901dc85bea4c82]::run_compiler::{closure#0}>::{closure#0}, core[17d6b7ce805ba05e]::result::Result<(), rustc_span[4d20b27f335b5d92]::ErrorGuaranteed>>::{closure#0}, core[17d6b7ce805ba05e]::result::Result<(), rustc_span[4d20b27f335b5d92]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[17d6b7ce805ba05e]::result::Result<(), rustc_span[4d20b27f335b5d92]::ErrorGuaranteed>>::{closure#1} as core[17d6b7ce805ba05e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7fe171058725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1e27cc9781dd2875
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/alloc/src/boxed.rs:2016:9
  37:     0x7fe171058725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4e0d9eddec111fd1
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/alloc/src/boxed.rs:2016:9
  38:     0x7fe171058725 - std::sys::pal::unix::thread::Thread::new::thread_start::h8ca0c4b428df1792
                               at /rustc/f70f19fef41cfdda75c92f163434c29ad046cf09/library/std/src/sys/pal/unix/thread.rs:108:17
  39:     0x7fe16aa94ac3 - start_thread
                               at ./nptl/pthread_create.c:442:8
  40:     0x7fe16ab26850 - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  41:                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.78.0-nightly (f70f19fef 2024-02-22) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_mod_privacy] checking privacy in top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
 --> /tmp/icemaker_global_tempdir.Lv2nHaQbve2G/rustc_testrunner_tmpdir_reporting.1yfawIGP80kJ/mvce.rs:1:13
  |
1 | fn test(s: &Self::Id) {
  |             ^^^^ `Self` is only available in impls, traits, and type definitions

error: aborting due to 1 previous error; 1 warning emitted

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

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Feb 22, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 22, 2024
@matthiaskrgr
Copy link
Member Author

#121206 cc @nnethercote

@nnethercote nnethercote self-assigned this Feb 22, 2024
nnethercote added a commit to nnethercote/rust that referenced this issue Feb 23, 2024
This was caused by 72b172b in rust-lang#121206. That commit removed an early
return from `analysis` when there are stashed errors. As a result, it's
possible to reach privacy analysis when there are stashed errors, which
means more code paths can be reached. One such code path was handled in
that commit, where a `span_bug` was changed to a `span_delayed_bug`.

This commit handles another such code path uncovered by fuzzing, in much
the same way.

Fixes rust-lang#121455.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 23, 2024
Allow for a missing `adt_def` in `NamePrivacyVisitor`.

This was caused by 72b172b in rust-lang#121206. That commit removed an early return from `analysis` when there are stashed errors. As a result, it's possible to reach privacy analysis when there are stashed errors, which means more code paths can be reached. One such code path was handled in that commit, where a `span_bug` was changed to a `span_delayed_bug`.

This commit handles another such code path uncovered by fuzzing, in much the same way.

Fixes rust-lang#121455.

r? `@oli-obk`
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 23, 2024
Rollup merge of rust-lang#121482 - nnethercote:fix-121455, r=oli-obk

Allow for a missing `adt_def` in `NamePrivacyVisitor`.

This was caused by 72b172b in rust-lang#121206. That commit removed an early return from `analysis` when there are stashed errors. As a result, it's possible to reach privacy analysis when there are stashed errors, which means more code paths can be reached. One such code path was handled in that commit, where a `span_bug` was changed to a `span_delayed_bug`.

This commit handles another such code path uncovered by fuzzing, in much the same way.

Fixes rust-lang#121455.

r? `@oli-obk`
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants