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

unbound memory growth after panic #121974

Closed
matthiaskrgr opened this issue Mar 4, 2024 · 3 comments · Fixed by #121993
Closed

unbound memory growth after panic #121974

matthiaskrgr opened this issue Mar 4, 2024 · 3 comments · Fixed by #121993
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 4, 2024

Code

from #121537

trait MyTrait {
    #[doc = MyTrait]
    fn myfun();
}

Rustc will crash "normally" (expected as the bug is not fixed) but when trying to print the query stack, rustc will eat up all available memory which is BAD.

Meta

rustc --version --verbose:

rustc 1.78.0-nightly (7606c1396 2024-03-04)
binary: rustc
commit-hash: 7606c13961ddc1174b70638e934df0439b7dc515
commit-date: 2024-03-04
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Error output

<output>
Backtrace

thread 'rustc' panicked at compiler/rustc_ast_lowering/src/lib.rs:962:56:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7ffb329cc224 - std::backtrace_rs::backtrace::libunwind::trace::ha9bdce7040d5dea4
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7ffb329cc224 - std::backtrace_rs::backtrace::trace_unsynchronized::h8e80669615b477e9
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ffb329cc224 - std::sys_common::backtrace::_print_fmt::hcf4d959aad241db4
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7ffb329cc224 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7d2529ed1cd6a35e
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ffb32a1d33c - core::fmt::rt::Argument::fmt::hb6acc149bc91f94e
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/core/src/fmt/rt.rs:142:9
   5:     0x7ffb32a1d33c - core::fmt::write::h07f4440a6bb50fa0
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/core/src/fmt/mod.rs:1120:17
   6:     0x7ffb329c0bbf - std::io::Write::write_fmt::h73f571dd622c3243
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/io/mod.rs:1846:15
   7:     0x7ffb329cbfd4 - std::sys_common::backtrace::_print::h9ef5634d5714da1b
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ffb329cbfd4 - std::sys_common::backtrace::print::h3a4538c072b7f968
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ffb329ced0b - std::panicking::default_hook::{{closure}}::hafb96db721edd26a
  10:     0x7ffb329cea67 - std::panicking::default_hook::he51c70478469d3b8
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/panicking.rs:292:9
  11:     0x7ffb2f686dfc - std[ce1c42f110f14421]::panicking::update_hook::<alloc[79a89dc93b620337]::boxed::Box<rustc_driver_impl[59494f0453ea5af6]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7ffb329cf470 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8254891e323ca763
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/alloc/src/boxed.rs:2030:9
  13:     0x7ffb329cf470 - std::panicking::rust_panic_with_hook::h49de3172531c6589
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/panicking.rs:783:13
  14:     0x7ffb329cf179 - std::panicking::begin_panic_handler::{{closure}}::h1d1f02b06e03fa2c
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/panicking.rs:649:13
  15:     0x7ffb329cc6f6 - std::sys_common::backtrace::__rust_end_short_backtrace::hc793b9e42bc684d8
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7ffb329ceee4 - rust_begin_unwind
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/panicking.rs:645:5
  17:     0x7ffb32a19855 - core::panicking::panic_fmt::ha62c22205b57a090
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/core/src/panicking.rs:72:14
  18:     0x7ffb32a19913 - core::panicking::panic::h4472113f8306584a
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/core/src/panicking.rs:144:5
  19:     0x7ffb32a195e6 - core::option::unwrap_failed::hb9ac757173c35f67
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/core/src/option.rs:1985:5
  20:     0x7ffb30b909a2 - <rustc_ast_lowering[6c6906526f1b1862]::LoweringContext>::lower_attrs
  21:     0x7ffb30b6fc6e - <rustc_ast_lowering[6c6906526f1b1862]::LoweringContext>::lower_assoc_item
  22:     0x7ffb30b6cd15 - <rustc_ast_lowering[6c6906526f1b1862]::item::ItemLowerer>::lower_node
  23:     0x7ffb317d6f42 - rustc_ast_lowering[6c6906526f1b1862]::lower_to_hir
  24:     0x7ffb317d66b6 - rustc_query_impl[26c48826fbaab4d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[26c48826fbaab4d5]::query_impl::hir_crate::dynamic_query::{closure#2}::{closure#0}, rustc_middle[17af273565a02f54]::query::erase::Erased<[u8; 8usize]>>
  25:     0x7ffb317d508e - rustc_query_system[ab339c616628e8a0]::query::plumbing::try_execute_query::<rustc_query_impl[26c48826fbaab4d5]::DynamicConfig<rustc_query_system[ab339c616628e8a0]::query::caches::SingleCache<rustc_middle[17af273565a02f54]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[26c48826fbaab4d5]::plumbing::QueryCtxt, false>
  26:     0x7ffb317d4c82 - rustc_query_impl[26c48826fbaab4d5]::query_impl::hir_crate::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7ffb30c673c3 - rustc_query_impl[26c48826fbaab4d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[26c48826fbaab4d5]::query_impl::hir_attrs::dynamic_query::{closure#2}::{closure#0}, rustc_middle[17af273565a02f54]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7ffb30c66925 - rustc_query_system[ab339c616628e8a0]::query::plumbing::try_execute_query::<rustc_query_impl[26c48826fbaab4d5]::DynamicConfig<rustc_query_system[ab339c616628e8a0]::query::caches::VecCache<rustc_hir[8f808412acee9cf8]::hir_id::OwnerId, rustc_middle[17af273565a02f54]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[26c48826fbaab4d5]::plumbing::QueryCtxt, false>
  29:     0x7ffb30c66689 - rustc_query_impl[26c48826fbaab4d5]::query_impl::hir_attrs::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7ffb30a1c2ea - <rustc_middle[17af273565a02f54]::hir::map::Map>::attrs
  31:     0x7ffb3150a603 - rustc_passes[69d23befb4dabec6]::entry::entry_fn
  32:     0x7ffb3150a598 - rustc_query_impl[26c48826fbaab4d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[26c48826fbaab4d5]::query_impl::entry_fn::dynamic_query::{closure#2}::{closure#0}, rustc_middle[17af273565a02f54]::query::erase::Erased<[u8; 12usize]>>
  33:     0x7ffb3150a573 - <rustc_query_impl[26c48826fbaab4d5]::query_impl::entry_fn::dynamic_query::{closure#2} as core[c7bf0aa57b07cfee]::ops::function::FnOnce<(rustc_middle[17af273565a02f54]::ty::context::TyCtxt, ())>>::call_once
  34:     0x7ffb31509e8a - rustc_query_system[ab339c616628e8a0]::query::plumbing::try_execute_query::<rustc_query_impl[26c48826fbaab4d5]::DynamicConfig<rustc_query_system[ab339c616628e8a0]::query::caches::SingleCache<rustc_middle[17af273565a02f54]::query::erase::Erased<[u8; 12usize]>>, false, false, false>, rustc_query_impl[26c48826fbaab4d5]::plumbing::QueryCtxt, false>
  35:     0x7ffb31509c45 - rustc_query_impl[26c48826fbaab4d5]::query_impl::entry_fn::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7ffb316fa2b4 - rustc_interface[7340c5359700de6d]::passes::analysis
  37:     0x7ffb316fa1d9 - rustc_query_impl[26c48826fbaab4d5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[26c48826fbaab4d5]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[17af273565a02f54]::query::erase::Erased<[u8; 1usize]>>
  38:     0x7ffb3173e525 - rustc_query_system[ab339c616628e8a0]::query::plumbing::try_execute_query::<rustc_query_impl[26c48826fbaab4d5]::DynamicConfig<rustc_query_system[ab339c616628e8a0]::query::caches::SingleCache<rustc_middle[17af273565a02f54]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[26c48826fbaab4d5]::plumbing::QueryCtxt, false>
  39:     0x7ffb3173e289 - rustc_query_impl[26c48826fbaab4d5]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7ffb3174d242 - rustc_interface[7340c5359700de6d]::interface::run_compiler::<core[c7bf0aa57b07cfee]::result::Result<(), rustc_span[11ebd0cf9c54dbf2]::ErrorGuaranteed>, rustc_driver_impl[59494f0453ea5af6]::run_compiler::{closure#0}>::{closure#0}
  41:     0x7ffb319f94e4 - std[ce1c42f110f14421]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7340c5359700de6d]::util::run_in_thread_with_globals<rustc_interface[7340c5359700de6d]::util::run_in_thread_pool_with_globals<rustc_interface[7340c5359700de6d]::interface::run_compiler<core[c7bf0aa57b07cfee]::result::Result<(), rustc_span[11ebd0cf9c54dbf2]::ErrorGuaranteed>, rustc_driver_impl[59494f0453ea5af6]::run_compiler::{closure#0}>::{closure#0}, core[c7bf0aa57b07cfee]::result::Result<(), rustc_span[11ebd0cf9c54dbf2]::ErrorGuaranteed>>::{closure#0}, core[c7bf0aa57b07cfee]::result::Result<(), rustc_span[11ebd0cf9c54dbf2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c7bf0aa57b07cfee]::result::Result<(), rustc_span[11ebd0cf9c54dbf2]::ErrorGuaranteed>>
  42:     0x7ffb319f9310 - <<std[ce1c42f110f14421]::thread::Builder>::spawn_unchecked_<rustc_interface[7340c5359700de6d]::util::run_in_thread_with_globals<rustc_interface[7340c5359700de6d]::util::run_in_thread_pool_with_globals<rustc_interface[7340c5359700de6d]::interface::run_compiler<core[c7bf0aa57b07cfee]::result::Result<(), rustc_span[11ebd0cf9c54dbf2]::ErrorGuaranteed>, rustc_driver_impl[59494f0453ea5af6]::run_compiler::{closure#0}>::{closure#0}, core[c7bf0aa57b07cfee]::result::Result<(), rustc_span[11ebd0cf9c54dbf2]::ErrorGuaranteed>>::{closure#0}, core[c7bf0aa57b07cfee]::result::Result<(), rustc_span[11ebd0cf9c54dbf2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c7bf0aa57b07cfee]::result::Result<(), rustc_span[11ebd0cf9c54dbf2]::ErrorGuaranteed>>::{closure#1} as core[c7bf0aa57b07cfee]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7ffb329d8c15 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd1519676561fa69a
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/alloc/src/boxed.rs:2016:9
  44:     0x7ffb329d8c15 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2631236f14039a09
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/alloc/src/boxed.rs:2016:9
  45:     0x7ffb329d8c15 - std::sys::pal::unix::thread::Thread::new::thread_start::hb46703a54bb9712d
                               at /rustc/7606c13961ddc1174b70638e934df0439b7dc515/library/std/src/sys/pal/unix/thread.rs:108:17
  46:     0x7ffb2c66e55a - <unknown>
  47:     0x7ffb2c6eba3c - <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: please attach the file at `/tmp/glacier2_hangtest/rustc-ice-2024-03-04T11_21_05-158378.txt` to your bug report

query stack during panic:
<OOM HAPPENS HERE>

@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 4, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 4, 2024
@matthiaskrgr matthiaskrgr added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Mar 4, 2024
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Mar 4, 2024
@jieyouxu jieyouxu added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 4, 2024
@matthiaskrgr
Copy link
Member Author

Its very likely hat this was caused by #121927 cc @Zoxc

@lukas-code
Copy link
Member

This looks like #112522 again. It was fixed in #112708, but the regression test doesn't actually test what it's supposed to, because it doesn't check for the "end of query stack" line. (This also means that we currently have an UI that will fill up your entire RAM and then get killed.)

The with_no_queries/with_reduced_queries calls here are needed to fix this, not sure why they got removed.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 4, 2024
jhpratt added a commit to jhpratt/rust that referenced this issue Mar 5, 2024
…compiler-errors

Avoid using unnecessary queries when printing the query stack in panics

This should fix rust-lang#121974. Alternative to rust-lang#121981.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 5, 2024
…compiler-errors

Avoid using unnecessary queries when printing the query stack in panics

This should fix rust-lang#121974. Alternative to rust-lang#121981.
@bors bors closed this as completed in 87dc3fc Mar 5, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 5, 2024
Rollup merge of rust-lang#121993 - Zoxc:query-stack-panic-queries, r=compiler-errors

Avoid using unnecessary queries when printing the query stack in panics

This should fix rust-lang#121974. Alternative to rust-lang#121981.
@apiraino
Copy link
Contributor

apiraino commented Mar 5, 2024

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-critical

@rustbot rustbot added P-critical Critical priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Mar 5, 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) ❄️ P-critical Critical priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
5 participants