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: named field access on non-ADT #120615

Closed
matthiaskrgr opened this issue Feb 3, 2024 · 3 comments · Fixed by #120616
Closed

ice: named field access on non-ADT #120615

matthiaskrgr opened this issue Feb 3, 2024 · 3 comments · Fixed by #120616
Assignees
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) 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 main() {
    let s = [(); {
        let mut n = 113383;
        while n != 0 {}
        n
    }];

    s.nonexistent_methodisize;
}

original:

//! This test tests two things at once:
//! 1. we error if a const evaluation hits the deny-by-default lint limit
//! 2. we do not ICE on invalid follow-up code

// compile-flags: -Z tiny-const-eval-limit

fn main() {
    // Tests the Collatz conjecture with an incorrect base case (0 instead of 1).
    // The value of `n` will loop indefinitely (4 - 2 - 1 - 4).
    let s = [(); {
        let mut n = 113383; // #20 in https://oeis.org/A006884
        while n != 0 {
            //~^ ERROR is taking a long time
            n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 };
        }
        n
    }];

    s.nonexistent_methodisize;
}

Version information

rustc 1.77.0-nightly (bf3c6c5be 2024-02-01)
binary: rustc
commit-hash: bf3c6c5bed498f41ad815641319a1ad9bcecb8e8
commit-date: 2024-02-01
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

warning: variable does not need to be mutable
 --> /tmp/icemaker_global_tempdir.aIHYhz8MWTTj/rustc_testrunner_tmpdir_reporting.BWUL70tAHs3y/mvce.rs:3:13
  |
3 |         let mut n = 113383;
  |             ----^
  |             |
  |             help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` on by default

error: constant evaluation is taking a long time
 --> /tmp/icemaker_global_tempdir.aIHYhz8MWTTj/rustc_testrunner_tmpdir_reporting.BWUL70tAHs3y/mvce.rs:4:9
  |
4 |         while n != 0 {}
  |         ^^^^^^^^^^^^^^^
  |
  = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
          If your compilation actually takes a long time, you can safely allow the lint.
help: the constant being evaluated
 --> /tmp/icemaker_global_tempdir.aIHYhz8MWTTj/rustc_testrunner_tmpdir_reporting.BWUL70tAHs3y/mvce.rs:2:18
  |
2 |       let s = [(); {
  |  __________________^
3 | |         let mut n = 113383;
4 | |         while n != 0 {}
5 | |         n
6 | |     }];
  | |_____^
  = note: `#[deny(long_running_const_eval)]` on by default

error: internal compiler error: compiler/rustc_passes/src/dead.rs:145:18: named field access on non-ADT
 --> /tmp/icemaker_global_tempdir.aIHYhz8MWTTj/rustc_testrunner_tmpdir_reporting.BWUL70tAHs3y/mvce.rs:8:5
  |
8 |     s.nonexistent_methodisize;
  |     ^

thread 'rustc' panicked at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/compiler/rustc_errors/src/lib.rs:855:41:
Box<dyn Any>
stack backtrace:
   0:     0x7feb52fafd16 - std::backtrace_rs::backtrace::libunwind::trace::he544685250360e22
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7feb52fafd16 - std::backtrace_rs::backtrace::trace_unsynchronized::h664adef12633380a
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7feb52fafd16 - std::sys_common::backtrace::_print_fmt::hba7ee045aeee07b0
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7feb52fafd16 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc80b7ff177a688f2
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7feb53002770 - core::fmt::rt::Argument::fmt::h605309ab4829b6b5
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/core/src/fmt/rt.rs:142:9
   5:     0x7feb53002770 - core::fmt::write::h5f24f526de99e105
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/core/src/fmt/mod.rs:1120:17
   6:     0x7feb52fa361f - std::io::Write::write_fmt::h711c920f97cd3d8c
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/io/mod.rs:1846:15
   7:     0x7feb52fafaf4 - std::sys_common::backtrace::_print::ha279702af2871260
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7feb52fafaf4 - std::sys_common::backtrace::print::hc1f3820f405abdd3
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7feb52fb2887 - std::panicking::default_hook::{{closure}}::h5058841d19c78172
  10:     0x7feb52fb25e9 - std::panicking::default_hook::h60a42497ec033f97
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/panicking.rs:292:9
  11:     0x7feb4fd371fc - std[4337b1e3d1c66af6]::panicking::update_hook::<alloc[6a28242b4f343ab9]::boxed::Box<rustc_driver_impl[e51f6499da6a94b9]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7feb52fb2fd6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h437fd8fcb0ff0cea
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/alloc/src/boxed.rs:2029:9
  13:     0x7feb52fb2fd6 - std::panicking::rust_panic_with_hook::h294fbe090fe44fa4
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/panicking.rs:785:13
  14:     0x7feb4fd693b4 - std[4337b1e3d1c66af6]::panicking::begin_panic::<rustc_errors[37e82e04e08bc148]::ExplicitBug>::{closure#0}
  15:     0x7feb4fd65aa6 - std[4337b1e3d1c66af6]::sys_common::backtrace::__rust_end_short_backtrace::<std[4337b1e3d1c66af6]::panicking::begin_panic<rustc_errors[37e82e04e08bc148]::ExplicitBug>::{closure#0}, !>
  16:     0x7feb4fd60d06 - std[4337b1e3d1c66af6]::panicking::begin_panic::<rustc_errors[37e82e04e08bc148]::ExplicitBug>
  17:     0x7feb4fd74591 - <rustc_errors[37e82e04e08bc148]::diagnostic_builder::BugAbort as rustc_errors[37e82e04e08bc148]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7feb503fc8bd - rustc_middle[9b442554c155189d]::util::bug::opt_span_bug_fmt::<rustc_span[ecf473d7733698d2]::span_encoding::Span>::{closure#0}
  19:     0x7feb503fc8ea - rustc_middle[9b442554c155189d]::ty::context::tls::with_opt::<rustc_middle[9b442554c155189d]::util::bug::opt_span_bug_fmt<rustc_span[ecf473d7733698d2]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7feb503f81a8 - rustc_middle[9b442554c155189d]::ty::context::tls::with_context_opt::<rustc_middle[9b442554c155189d]::ty::context::tls::with_opt<rustc_middle[9b442554c155189d]::util::bug::opt_span_bug_fmt<rustc_span[ecf473d7733698d2]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7feb503f7574 - rustc_middle[9b442554c155189d]::util::bug::span_bug_fmt::<rustc_span[ecf473d7733698d2]::span_encoding::Span>
  22:     0x7feb510f474f - <rustc_passes[4dd4d7a412ef7d49]::dead::MarkSymbolVisitor as rustc_hir[1f4f973af63e82cc]::intravisit::Visitor>::visit_expr
  23:     0x7feb510f1c04 - <rustc_passes[4dd4d7a412ef7d49]::dead::MarkSymbolVisitor as rustc_hir[1f4f973af63e82cc]::intravisit::Visitor>::visit_block
  24:     0x7feb5131bc26 - rustc_hir[1f4f973af63e82cc]::intravisit::walk_item::<rustc_passes[4dd4d7a412ef7d49]::dead::MarkSymbolVisitor>
  25:     0x7feb51fce711 - rustc_passes[4dd4d7a412ef7d49]::dead::live_symbols_and_ignored_derived_traits
  26:     0x7feb51fcd7ac - rustc_query_impl[5a78334436849816]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5a78334436849816]::query_impl::live_symbols_and_ignored_derived_traits::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9b442554c155189d]::query::erase::Erased<[u8; 8usize]>>
  27:     0x7feb51da4af2 - rustc_query_system[f1aaee53077b1b15]::query::plumbing::try_execute_query::<rustc_query_impl[5a78334436849816]::DynamicConfig<rustc_query_system[f1aaee53077b1b15]::query::caches::SingleCache<rustc_middle[9b442554c155189d]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[5a78334436849816]::plumbing::QueryCtxt, false>
  28:     0x7feb51da4286 - rustc_query_impl[5a78334436849816]::query_impl::live_symbols_and_ignored_derived_traits::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7feb5188dc09 - rustc_passes[4dd4d7a412ef7d49]::dead::check_mod_deathness
  30:     0x7feb5188daab - rustc_query_impl[5a78334436849816]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5a78334436849816]::query_impl::check_mod_deathness::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9b442554c155189d]::query::erase::Erased<[u8; 0usize]>>
  31:     0x7feb51bdf8bb - rustc_query_system[f1aaee53077b1b15]::query::plumbing::try_execute_query::<rustc_query_impl[5a78334436849816]::DynamicConfig<rustc_query_system[f1aaee53077b1b15]::query::caches::DefaultCache<rustc_span[ecf473d7733698d2]::def_id::LocalModDefId, rustc_middle[9b442554c155189d]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[5a78334436849816]::plumbing::QueryCtxt, false>
  32:     0x7feb51bdec83 - rustc_query_impl[5a78334436849816]::query_impl::check_mod_deathness::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7feb519eb050 - rustc_interface[e57535df52585ed5]::passes::analysis
  34:     0x7feb519e9d9f - rustc_query_impl[5a78334436849816]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[5a78334436849816]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9b442554c155189d]::query::erase::Erased<[u8; 1usize]>>
  35:     0x7feb51d0b6b2 - rustc_query_system[f1aaee53077b1b15]::query::plumbing::try_execute_query::<rustc_query_impl[5a78334436849816]::DynamicConfig<rustc_query_system[f1aaee53077b1b15]::query::caches::SingleCache<rustc_middle[9b442554c155189d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[5a78334436849816]::plumbing::QueryCtxt, false>
  36:     0x7feb51d0b415 - rustc_query_impl[5a78334436849816]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7feb51d182b6 - rustc_interface[e57535df52585ed5]::interface::run_compiler::<core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>, rustc_driver_impl[e51f6499da6a94b9]::run_compiler::{closure#0}>::{closure#0}
  38:     0x7feb519ada86 - std[4337b1e3d1c66af6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e57535df52585ed5]::util::run_in_thread_with_globals<rustc_interface[e57535df52585ed5]::util::run_in_thread_pool_with_globals<rustc_interface[e57535df52585ed5]::interface::run_compiler<core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>, rustc_driver_impl[e51f6499da6a94b9]::run_compiler::{closure#0}>::{closure#0}, core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>>::{closure#0}, core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>>
  39:     0x7feb519ad8b3 - <<std[4337b1e3d1c66af6]::thread::Builder>::spawn_unchecked_<rustc_interface[e57535df52585ed5]::util::run_in_thread_with_globals<rustc_interface[e57535df52585ed5]::util::run_in_thread_pool_with_globals<rustc_interface[e57535df52585ed5]::interface::run_compiler<core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>, rustc_driver_impl[e51f6499da6a94b9]::run_compiler::{closure#0}>::{closure#0}, core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>>::{closure#0}, core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>>::{closure#1} as core[cc6cd760d986f799]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7feb52fbc675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc4b9a6efba849e51
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/alloc/src/boxed.rs:2015:9
  41:     0x7feb52fbc675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc525ee5ac423ddcd
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/alloc/src/boxed.rs:2015:9
  42:     0x7feb52fbc675 - std::sys::pal::unix::thread::Thread::new::thread_start::h31b81f67226864c0
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/sys/pal/unix/thread.rs:108:17
  43:     0x7feb4ce9b9eb - <unknown>
  44:     0x7feb4cf1f7cc - <unknown>
  45:                0x0 - <unknown>

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.77.0-nightly (bf3c6c5be 2024-02-01) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [live_symbols_and_ignored_derived_traits] finding live symbols in crate
#1 [check_mod_deathness] checking deathness of variables in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted


@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 3, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 3, 2024
@matthiaskrgr
Copy link
Member Author

Bisects to nightly-2023-06-02

commit[0] 2023-05-31: Auto merge of #111913 - oli-obk:valtrees2, r=lcnr
commit[1] 2023-05-31: Auto merge of #110807 - petrochenkov:strictflavor, r=lqd,wesleywiser
commit[2] 2023-06-01: Auto merge of #111567 - Urgau:uplift_cast_ref_to_mut, r=b-naber
commit[3] 2023-06-01: Auto merge of #103877 - oli-obk:const_eval_step_limit, r=fee1-dead
commit[4] 2023-06-01: Auto merge of #112164 - Dylan-DPC:rollup-93zj7jw, r=Dylan-DPC
commit[5] 2023-06-01: Auto merge of #112002 - saethlin:enable-sroa, r=oli-obk,scottmcm
commit[6] 2023-06-01: Auto merge of #112040 - cjgillot:separate-const-switch, r=oli-obk
commit[7] 2023-06-01: Auto merge of #111660 - Kobzol:try-build-skip-docs, r=mark-simulacrum

ERROR: no CI builds available between 871b595 and d59363a within last 167 days

@fmease
Copy link
Member

fmease commented Feb 3, 2024

Minimized:

fn main() {
    [(); loop {}].field;
}

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 3, 2024
@fmease fmease self-assigned this Feb 3, 2024
@fmease fmease added the A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) label Feb 3, 2024
@fmease
Copy link
Member

fmease commented Feb 3, 2024

Very likely #103877 btw.

@bors bors closed this as completed in 326839b Feb 4, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 4, 2024
Rollup merge of rust-lang#120616 - fmease:fix-ice-const-eval-fail-undef-field-access, r=compiler-errors

Fix ICE on field access on a tainted type after const-eval failure

Fixes rust-lang#120615.

r? oli-obk or compiler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) 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.

3 participants