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 in compiler/rustc_lint/src/internal.rs , no type_dependent_def_id #122177

Closed
matthiaskrgr opened this issue Mar 8, 2024 · 0 comments · Fixed by #122181
Closed

ICE: None in compiler/rustc_lint/src/internal.rs , no type_dependent_def_id #122177

matthiaskrgr opened this issue Mar 8, 2024 · 0 comments · Fixed by #122181
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 main() {
    let s = [(); {
        let mut n = 113383;
        while n != 0 {}
        n
    }];

    s.nonexistent_method();
}

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() {
    // Paren generic args in AnonymousReportError
    // 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_method();
}

Version information

rustc 1.78.0-nightly (9c3ad802d 2024-03-07)
binary: rustc
commit-hash: 9c3ad802d9b9633d60d3a74668eb1be819212d34
commit-date: 2024-03-07
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zunstable-options

Program output

warning: variable does not need to be mutable
 --> /tmp/icemaker_global_tempdir.tnThSS4Op8nc/rustc_testrunner_tmpdir_reporting.U0bd0T4nR0Ub/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.tnThSS4Op8nc/rustc_testrunner_tmpdir_reporting.U0bd0T4nR0Ub/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.tnThSS4Op8nc/rustc_testrunner_tmpdir_reporting.U0bd0T4nR0Ub/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

thread 'rustc' panicked at compiler/rustc_lint/src/internal.rs:383:85:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7f165c840744 - std::backtrace_rs::backtrace::libunwind::trace::hd79b9078a34dff8c
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f165c840744 - std::backtrace_rs::backtrace::trace_unsynchronized::hb030a00513a1f538
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f165c840744 - std::sys_common::backtrace::_print_fmt::h9e8f2e41a9fc6909
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f165c840744 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6f607e0d4dd3a9cf
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f165c891a7c - core::fmt::rt::Argument::fmt::h09f11d700bacd96c
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/core/src/fmt/rt.rs:142:9
   5:     0x7f165c891a7c - core::fmt::write_internal::h310f192d94aa585c
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/core/src/fmt/mod.rs:1143:17
   6:     0x7f165c835157 - core::fmt::write::hd3de438db38ee127
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/core/src/fmt/mod.rs:1125:67
   7:     0x7f165c835157 - std::io::Write::write_fmt::h3b33808356b90221
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/io/mod.rs:1846:15
   8:     0x7f165c8404f4 - std::sys_common::backtrace::_print::h611f07983f175f23
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/sys_common/backtrace.rs:47:5
   9:     0x7f165c8404f4 - std::sys_common::backtrace::print::h6363f60fb7870801
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/sys_common/backtrace.rs:34:9
  10:     0x7f165c8430fb - std::panicking::default_hook::{{closure}}::h918979fb10785ece
  11:     0x7f165c842e57 - std::panicking::default_hook::h7cb2ae29c5cb7a04
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/panicking.rs:292:9
  12:     0x7f165945f79c - std[3bcdf4610aa8fcfe]::panicking::update_hook::<alloc[693dccb2014d768d]::boxed::Box<rustc_driver_impl[31aa33c569e87665]::install_ice_hook::{closure#0}>>::{closure#0}
  13:     0x7f165c843812 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hd696ff45800b08d8
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/alloc/src/boxed.rs:2030:9
  14:     0x7f165c843812 - std::panicking::rust_panic_with_hook::h50affda8314ad6e5
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/panicking.rs:783:13
  15:     0x7f165c843599 - std::panicking::begin_panic_handler::{{closure}}::h8093c7c84d3aa062
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/panicking.rs:649:13
  16:     0x7f165c840c16 - std::sys_common::backtrace::__rust_end_short_backtrace::h1bc420f809db97be
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/sys_common/backtrace.rs:171:18
  17:     0x7f165c8432d4 - rust_begin_unwind
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/panicking.rs:645:5
  18:     0x7f165c88dcd5 - core::panicking::panic_fmt::h3e7482ac39c7599a
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/core/src/panicking.rs:72:14
  19:     0x7f165c88dd93 - core::panicking::panic::hd7ed5adeff7473ba
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/core/src/panicking.rs:145:5
  20:     0x7f165c88da36 - core::option::unwrap_failed::hb356953c4b4f9864
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/core/src/option.rs:1985:5
  21:     0x7f16597ec15d - <rustc_lint[2b73a2429b57f1ff]::internal::Diagnostics as rustc_lint[2b73a2429b57f1ff]::passes::LateLintPass>::check_expr
  22:     0x7f16597ed262 - <rustc_lint[2b73a2429b57f1ff]::late::LateContextAndPass<rustc_lint[2b73a2429b57f1ff]::late::RuntimeCombinedLateLintPass> as rustc_hir[8206a477fef721a0]::intravisit::Visitor>::visit_expr::{closure#0}
  23:     0x7f16597ed0f8 - <rustc_lint[2b73a2429b57f1ff]::late::LateContextAndPass<rustc_lint[2b73a2429b57f1ff]::late::RuntimeCombinedLateLintPass> as rustc_hir[8206a477fef721a0]::intravisit::Visitor>::visit_expr
  24:     0x7f16597edeac - <rustc_lint[2b73a2429b57f1ff]::late::LateContextAndPass<rustc_lint[2b73a2429b57f1ff]::late::RuntimeCombinedLateLintPass> as rustc_hir[8206a477fef721a0]::intravisit::Visitor>::visit_block
  25:     0x7f16597ed704 - <rustc_lint[2b73a2429b57f1ff]::late::LateContextAndPass<rustc_lint[2b73a2429b57f1ff]::late::RuntimeCombinedLateLintPass> as rustc_hir[8206a477fef721a0]::intravisit::Visitor>::visit_expr::{closure#0}
  26:     0x7f16597ed0f8 - <rustc_lint[2b73a2429b57f1ff]::late::LateContextAndPass<rustc_lint[2b73a2429b57f1ff]::late::RuntimeCombinedLateLintPass> as rustc_hir[8206a477fef721a0]::intravisit::Visitor>::visit_expr
  27:     0x7f16597ecff8 - <rustc_lint[2b73a2429b57f1ff]::late::LateContextAndPass<rustc_lint[2b73a2429b57f1ff]::late::RuntimeCombinedLateLintPass> as rustc_hir[8206a477fef721a0]::intravisit::Visitor>::visit_nested_body
  28:     0x7f16597edcb4 - <rustc_lint[2b73a2429b57f1ff]::late::LateContextAndPass<rustc_lint[2b73a2429b57f1ff]::late::RuntimeCombinedLateLintPass> as rustc_hir[8206a477fef721a0]::intravisit::Visitor>::visit_fn
  29:     0x7f16597dcdd4 - <rustc_lint[2b73a2429b57f1ff]::late::LateContextAndPass<rustc_lint[2b73a2429b57f1ff]::late::RuntimeCombinedLateLintPass> as rustc_hir[8206a477fef721a0]::intravisit::Visitor>::visit_nested_item
  30:     0x7f165abab02b - rustc_lint[2b73a2429b57f1ff]::lint_mod
  31:     0x7f165abaab67 - rustc_query_impl[ebede55f2ba688a3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ebede55f2ba688a3]::query_impl::lint_mod::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fd081ac05546064c]::query::erase::Erased<[u8; 0usize]>>
  32:     0x7f165b412fad - rustc_query_system[67c50b8e9e85bc4b]::query::plumbing::try_execute_query::<rustc_query_impl[ebede55f2ba688a3]::DynamicConfig<rustc_query_system[67c50b8e9e85bc4b]::query::caches::DefaultCache<rustc_span[9b5de1c806cc2c00]::def_id::LocalModDefId, rustc_middle[fd081ac05546064c]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[ebede55f2ba688a3]::plumbing::QueryCtxt, false>
  33:     0x7f165b4118bf - rustc_query_impl[ebede55f2ba688a3]::query_impl::lint_mod::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f165b41145f - rustc_lint[2b73a2429b57f1ff]::late::check_crate::{closure#1}
  35:     0x7f165b410e5e - rustc_lint[2b73a2429b57f1ff]::late::check_crate
  36:     0x7f165b3514a0 - rustc_interface[7cf7fd78b82fa32a]::passes::analysis
  37:     0x7f165b350119 - rustc_query_impl[ebede55f2ba688a3]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ebede55f2ba688a3]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[fd081ac05546064c]::query::erase::Erased<[u8; 1usize]>>
  38:     0x7f165b592265 - rustc_query_system[67c50b8e9e85bc4b]::query::plumbing::try_execute_query::<rustc_query_impl[ebede55f2ba688a3]::DynamicConfig<rustc_query_system[67c50b8e9e85bc4b]::query::caches::SingleCache<rustc_middle[fd081ac05546064c]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ebede55f2ba688a3]::plumbing::QueryCtxt, false>
  39:     0x7f165b591fc9 - rustc_query_impl[ebede55f2ba688a3]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f165b51bf8f - rustc_interface[7cf7fd78b82fa32a]::interface::run_compiler::<core[93adbeecb64913d3]::result::Result<(), rustc_span[9b5de1c806cc2c00]::ErrorGuaranteed>, rustc_driver_impl[31aa33c569e87665]::run_compiler::{closure#0}>::{closure#0}
  41:     0x7f165b7d0005 - std[3bcdf4610aa8fcfe]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7cf7fd78b82fa32a]::util::run_in_thread_with_globals<rustc_interface[7cf7fd78b82fa32a]::util::run_in_thread_pool_with_globals<rustc_interface[7cf7fd78b82fa32a]::interface::run_compiler<core[93adbeecb64913d3]::result::Result<(), rustc_span[9b5de1c806cc2c00]::ErrorGuaranteed>, rustc_driver_impl[31aa33c569e87665]::run_compiler::{closure#0}>::{closure#0}, core[93adbeecb64913d3]::result::Result<(), rustc_span[9b5de1c806cc2c00]::ErrorGuaranteed>>::{closure#0}, core[93adbeecb64913d3]::result::Result<(), rustc_span[9b5de1c806cc2c00]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[93adbeecb64913d3]::result::Result<(), rustc_span[9b5de1c806cc2c00]::ErrorGuaranteed>>
  42:     0x7f165b7cfe32 - <<std[3bcdf4610aa8fcfe]::thread::Builder>::spawn_unchecked_<rustc_interface[7cf7fd78b82fa32a]::util::run_in_thread_with_globals<rustc_interface[7cf7fd78b82fa32a]::util::run_in_thread_pool_with_globals<rustc_interface[7cf7fd78b82fa32a]::interface::run_compiler<core[93adbeecb64913d3]::result::Result<(), rustc_span[9b5de1c806cc2c00]::ErrorGuaranteed>, rustc_driver_impl[31aa33c569e87665]::run_compiler::{closure#0}>::{closure#0}, core[93adbeecb64913d3]::result::Result<(), rustc_span[9b5de1c806cc2c00]::ErrorGuaranteed>>::{closure#0}, core[93adbeecb64913d3]::result::Result<(), rustc_span[9b5de1c806cc2c00]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[93adbeecb64913d3]::result::Result<(), rustc_span[9b5de1c806cc2c00]::ErrorGuaranteed>>::{closure#1} as core[93adbeecb64913d3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f165c84cf75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdd6038e2544823b8
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/alloc/src/boxed.rs:2016:9
  44:     0x7f165c84cf75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3c0d32827bf54df1
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/alloc/src/boxed.rs:2016:9
  45:     0x7f165c84cf75 - std::sys::pal::unix::thread::Thread::new::thread_start::h05976f6f44bd9999
                               at /rustc/9c3ad802d9b9633d60d3a74668eb1be819212d34/library/std/src/sys/pal/unix/thread.rs:108:17
  46:     0x7f16564a955a - <unknown>
  47:     0x7f1656526a3c - <unknown>
  48:                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 (9c3ad802d 2024-03-07) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unstable-options -Z dump-mir-dir=dir

query stack during panic:
#0 [lint_mod] linting top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error; 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 Mar 8, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 8, 2024
@matthiaskrgr matthiaskrgr changed the title ICE: None in compiler/rustc_lint/src/internal.rs ICE: None in compiler/rustc_lint/src/internal.rs , no type_dependent_def_id Mar 8, 2024
@chenyukang chenyukang self-assigned this Mar 8, 2024
@bors bors closed this as completed in a08a5d4 Mar 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 8, 2024
Rollup merge of rust-lang#122181 - chenyukang:yukang-fix-late-lint-crash, r=oli-obk

Fix crash in internal late lint checking

Fixes rust-lang#122177
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 9, 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