Skip to content

Inlined recursive type error can be dodged, leading to compiler overflowing its stack #98842

Closed
@danielhenrymantilla

Description

@danielhenrymantilla
// If the inner `Foo` is named through an associated type, the "infinite size" error does not occur.
struct Foo(<&'static Foo as ::core::ops::Deref>::Target);
// But Rust will be unable to know whether `Foo` is sized or not,
// and it will infinitely recurse somewhere trying to figure out the size of this pointer (is my guess):
const _: *const Foo = 0 as _;

This happens on 1.0.0, stable, and nightly (haven't checked the others).

Error

image

On older toolchains, it succintly says:

thread rustc has overflowed its stack

On newer ones, it yields:

/opt/compiler-explorer/rust-nightly/bin/../lib/librustc_driver-82e4545cc4765a53.so(+0x519703)[0x7f215aa83703]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x143c0)[0x7f215a1ca3c0]
/opt/compiler-explorer/rust-nightly/bin/../lib/librustc_driver-82e4545cc4765a53.so(_RNvXNtNtNtCslVMVSX5WZa3_21rustc_trait_selection6traits5query19evaluate_obligationNtNtCskKqV9GDjbtg_11rustc_infer5infer9InferCtxtNtB2_12InferCtxtExt34predicate_must_hold_modulo_regions+0x26)[0x7f215c91e606]
/opt/compiler-explorer/rust-nightly/bin/../lib/librustc_driver-82e4545cc4765a53.so(_RNvNtCslVMVSX5WZa3_21rustc_trait_selection6traits39type_known_to_meet_bound_modulo_regions+0x122)[0x7f215c980332]
/opt/compiler-explorer/rust-nightly/bin/../lib/librustc_driver-82e4545cc4765a53.so(+0x2939da2)[0x7f215cea3da2]
/opt/compiler-explorer/rust-nightly/bin/../lib/librustc_driver-82e4545cc4765a53.so(+0x2939e5a)[0x7f215cea3e5a]

/opt/compiler-explorer/rust-nightly/bin/../lib/librustc_driver-82e4545cc4765a53.so(+0x2939e5a)[0x7f215cea3e5a]

Demo

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions