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

infinite(?) recursion / memory allocation loop / out of memory panic #119625

Closed
AnAverageGitUser opened this issue Jan 5, 2024 · 1 comment · Fixed by #119638
Closed

infinite(?) recursion / memory allocation loop / out of memory panic #119625

AnAverageGitUser opened this issue Jan 5, 2024 · 1 comment · Fixed by #119638
Labels
C-bug Category: This is a bug. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@AnAverageGitUser
Copy link

Code

Minimal reproducible example: minimal_reproducible_example.zip

Meta

rustc --version --verbose:

rustc 1.77.0-nightly (f688dd684 2024-01-04)
binary: rustc                                        
commit-hash: f688dd684faca5b31b156fac2c6e0ae81fc9bc90
commit-date: 2024-01-04                              
host: x86_64-pc-windows-msvc                         
release: 1.77.0-nightly                              
LLVM version: 17.0.6

The error was also present within version "1.76.0-nightly".

Error output

Looks like it tries to allocate a lot of memory until on windows the swap file was full and further memory allocation fails.

unable to allocate fiber: Die Auslagerungsdatei ist zu klein, um diesen Vorgang durchzuführen. (os error 1455)

Backtrace: rustc-ice-2024-01-05T16_46_09-15824.txt

@AnAverageGitUser AnAverageGitUser added 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. labels Jan 5, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 5, 2024
@lukas-code
Copy link
Member

lukas-code commented Jan 5, 2024

smaller repro:

// crate a

mod m {
    pub struct Uuid(());

    impl Uuid {
        pub fn encode_buffer() -> [u8; LENGTH] {
            []
        }
    }
    const LENGTH: usize = 0;
}

pub use m::Uuid;
// crate b

const CONST_NAME: a::Uuid = a::Uuid(());

fn main() {}

relevant part of backtrace:

#60 0x00007ffff7f56c70 in core::fmt::rt::Argument::fmt () at library/core/src/fmt/rt.rs:142
#61 core::fmt::write () at library/core/src/fmt/mod.rs:1120
#62 0x00007ffff7f3d2c9 in core::fmt::Write::write_fmt::{impl#1}::spec_write_fmt<alloc::string::String> () at library/core/src/fmt/mod.rs:211
#63 core::fmt::Write::write_fmt<alloc::string::String> () at library/core/src/fmt/mod.rs:215
#64 alloc::fmt::format::format_inner () at library/alloc/src/fmt.rs:612
#65 0x00007ffff635b7e9 in alloc::fmt::format::{closure#0} () at library/alloc/src/fmt.rs:616
#66 core::option::Option::map_or_else<&str, alloc::string::String, alloc::fmt::format::{closure_env#0}, fn(&str) -> alloc::string::String> () at library/core/src/option.rs:1173
#67 alloc::fmt::format () at library/alloc/src/fmt.rs:616
#68 rustc_middle::query::descs::resolve_instance () at compiler/rustc_middle/src/query/mod.rs:110
#69 0x00007ffff53a2679 in rustc_query_impl::plumbing::create_query_frame<rustc_middle::ty::ParamEnvAnd<(rustc_span::def_id::DefId, &rustc_middle::ty::list::List<rustc_middle::ty::generic_args::GenericArg>)>> () at compiler/rustc_query_impl/src/plumbing.rs:315
#70 0x00007ffff52fc114 in rustc_query_impl::query_impl::resolve_instance::try_collect_active_jobs::{closure#0} () at compiler/rustc_query_impl/src/plumbing.rs:666
#71 core::ops::function::FnOnce::call_once<rustc_query_impl::query_impl::resolve_instance::try_collect_active_jobs::{closure_env#0}, (rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<(rustc_span::def_id::DefId, &rustc_middle::ty::list::List<rustc_middle::ty::generic_args::GenericArg>)>)> () at library/core/src/ops/function.rs:250
#72 0x00007ffff55da13b in rustc_query_system::query::plumbing::QueryState::try_collect_active_jobs<rustc_middle::ty::ParamEnvAnd<(rustc_span::def_id::DefId, &rustc_middle::ty::list::List<rustc_middle::ty::generic_args::GenericArg>)>, rustc_middle::ty::context::TyCtxt> () at compiler/rustc_query_system/src/query/plumbing.rs:88
#73 0x00007ffff52fcb3a in rustc_query_impl::query_impl::resolve_instance::try_collect_active_jobs () at compiler/rustc_query_impl/src/plumbing.rs:668
#74 0x00007ffff54a76f6 in rustc_query_impl::plumbing::{impl#3}::collect_active_jobs () at compiler/rustc_query_impl/src/plumbing.rs:87
#75 0x00007ffff3b2bcee in rustc_query_system::query::plumbing::cycle_error<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt> () at compiler/rustc_query_system/src/query/plumbing.rs:253
#76 0x00007ffff55f636c in rustc_query_system::query::plumbing::try_execute_query<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true> () at compiler/rustc_query_system/src/query/plumbing.rs:371
#77 0x00007ffff53eacce in rustc_query_system::query::plumbing::get_query_incr::{closure#0}<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt> () at compiler/rustc_query_system/src/query/plumbing.rs:834
#78 stacker::maybe_grow<(rustc_middle::query::erase::Erased<[u8; 24]>, core::option::Option<rustc_query_system::dep_graph::graph::DepNodeIndex>), rustc_query_system::query::plumbing::get_query_incr::{closure_env#0}<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>> () at /home/lukas/.cargo/registry/src/index.crates.io-6f17d22bba15001f/stacker-0.1.15/src/lib.rs:55
#79 rustc_data_structures::stack::ensure_sufficient_stack<(rustc_middle::query::erase::Erased<[u8; 24]>, core::option::Option<rustc_query_system::dep_graph::graph::DepNodeIndex>), rustc_query_system::query::plumbing::get_query_incr::{closure_env#0}<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt>> () at compiler/rustc_data_structures/src/stack.rs:17
#80 rustc_query_system::query::plumbing::get_query_incr<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt> () at compiler/rustc_query_system/src/query/plumbing.rs:833
#81 rustc_query_impl::query_impl::limits::get_query_incr::__rust_end_short_backtrace () at compiler/rustc_query_impl/src/plumbing.rs:543
#82 0x00007ffff639e900 in rustc_middle::query::plumbing::query_get_at<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 24]>>> () at compiler/rustc_middle/src/query/plumbing.rs:156
#83 rustc_middle::query::plumbing::TyCtxtAt::limits () at compiler/rustc_middle/src/query/plumbing.rs:438
#84 rustc_middle::ty::context::TyCtxt::limits () at compiler/rustc_middle/src/query/plumbing.rs:429
#85 rustc_middle::ty::context::TyCtxt::type_length_limit () at compiler/rustc_middle/src/ty/context.rs:1305
#86 0x00007ffff637bc1e in rustc_middle::ty::instance::{impl#3}::fmt::{closure#0} () at compiler/rustc_middle/src/ty/instance.rs:333
#87 rustc_middle::ty::context::tls::with::{closure#0}<rustc_middle::ty::instance::{impl#3}::fmt::{closure_env#0}, core::result::Result<(), core::fmt::Error>> () at compiler/rustc_middle/src/ty/context/tls.rs:144
#88 rustc_middle::ty::context::tls::with_context::{closure#0}<rustc_middle::ty::context::tls::with::{closure_env#0}<rustc_middle::ty::instance::{impl#3}::fmt::{closure_env#0}, core::result::Result<(), core::fmt::Error>>, core::result::Result<(), core::fmt::Error>> () at compiler/rustc_middle/src/ty/context/tls.rs:111
#89 rustc_middle::ty::context::tls::with_context_opt<rustc_middle::ty::context::tls::with_context::{closure_env#0}<rustc_middle::ty::context::tls::with::{closure_env#0}<rustc_middle::ty::instance::{impl#3}::fmt::{closure_env#0}, core::result::Result<(), core::fmt::Error>>, core::result::Result<(), core::fmt::Error>>, core::result::Result<(), core::fmt::Error>> () at compiler/rustc_middle/src/ty/context/tls.rs:100
#90 rustc_middle::ty::context::tls::with_context<rustc_middle::ty::context::tls::with::{closure_env#0}<rustc_middle::ty::instance::{impl#3}::fmt::{closure_env#0}, core::result::Result<(), core::fmt::Error>>, core::result::Result<(), core::fmt::Error>> () at compiler/rustc_middle/src/ty/context/tls.rs:111
#91 rustc_middle::ty::context::tls::with<rustc_middle::ty::instance::{impl#3}::fmt::{closure_env#0}, core::result::Result<(), core::fmt::Error>> () at compiler/rustc_middle/src/ty/context/tls.rs:144
#92 rustc_middle::ty::instance::{impl#3}::fmt () at compiler/rustc_middle/src/ty/instance.rs:333
... repeating

compiler-errors added a commit to compiler-errors/rust that referenced this issue Jan 6, 2024
…le-error, r=cjgillot

fix cyle error when suggesting to use associated function instead of constructor

Fixes rust-lang#119625.

The first commit fixes the infinite recursion and makes the cycle error actually show up. We do this by making the `Display` for `ty::Instance` impl  respect `with_no_queries` so that it can be used in query descriptions.

The second commit fixes the cycle error `resolver_for_lowering` -> `normalize` -> `resolve_instance` (for evaluating const) -> `lang_items` (for `drop_in_place`) -> `resolver_for_lowering` (for collecting lang items). We do this by simply skipping the suggestion when encountering an unnormalized type.
@bors bors closed this as completed in 61c776a Jan 6, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 6, 2024
Rollup merge of rust-lang#119638 - lukas-code:suggest-constructor-cycle-error, r=cjgillot

fix cyle error when suggesting to use associated function instead of constructor

Fixes rust-lang#119625.

The first commit fixes the infinite recursion and makes the cycle error actually show up. We do this by making the `Display` for `ty::Instance` impl  respect `with_no_queries` so that it can be used in query descriptions.

The second commit fixes the cycle error `resolver_for_lowering` -> `normalize` -> `resolve_instance` (for evaluating const) -> `lang_items` (for `drop_in_place`) -> `resolver_for_lowering` (for collecting lang items). We do this by simply skipping the suggestion when encountering an unnormalized type.
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 6, 2024
@saethlin saethlin added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 7, 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-compilemem Issue: Problems and improvements with respect to memory usage during compilation. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. 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.

5 participants