rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.82k stars 12.77k forks source link

stack overflow during debuginfo generation #121538

Open matthiaskrgr opened 9 months ago

matthiaskrgr commented 9 months ago

I tried this code:

use std::marker::PhantomData;

struct Digit<T> {
    elem: T
}

struct Node<T:'static> { m: PhantomData<&'static T> }

enum FingerTree<T:'static> {
    Single(T),

    Deep(
        Digit<T>,
        Node<FingerTree<Node<T>>>,
        )
}

enum Wrapper<T:'static> {
    Simple,
    Other(FingerTree<T>),
}

fn main() {
    let w =
        Some(Wrapper::Simple::<u32>);

}

This builds until you go for -Cdebuginfo=2

Meta

rustc --version --verbose:

rustc 1.78.0-nightly (8f359beca 2024-02-23)
binary: rustc
commit-hash: 8f359beca4e58bc3ae795a666301a8f47023044c
commit-date: 2024-02-23
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0
Backtrace

``` /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x2e9fcb3)[0x7f2de429fcb3] /usr/lib/libc.so.6(+0x40770)[0x7f2de1131770] /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(_RNvNtNtCsiCYefPgEVI8_17rustc_codegen_ssa9debuginfo10type_names14push_item_name+0x1b)[0x7f2de5629ddb] /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(_RNvNtNtCsiCYefPgEVI8_17rustc_codegen_ssa9debuginfo10type_names14push_item_name+0x1b4)[0x7f2de5629f74] /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x4507a70)[0x7f2de5907a70] ### cycle encountered after 5 frames with period 6 /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x450674f)[0x7f2de590674f] /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x4507a8b)[0x7f2de5907a8b] /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x450674f)[0x7f2de590674f] /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x4507a8b)[0x7f2de5907a8b] /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x450674f)[0x7f2de590674f] /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x4507a8b)[0x7f2de5907a8b] ### recursed 41 times /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x450674f)[0x7f2de590674f] /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x4507a8b)[0x7f2de5907a8b] /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x450674f)[0x7f2de590674f] /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x4507a8b)[0x7f2de5907a8b] /home/matthias/.rustup/toolchains/master/lib/librustc_driver-3110cac9722aa818.so(+0x450674f)[0x7f2de590674f] note: rustc unexpectedly overflowed its stack! this is a bug note: maximum backtrace depth reached, frames may have been lost note: we would appreciate a report at https://github.com/rust-lang/rust note: backtrace dumped due to SIGSEGV! resuming signal [1] 3369027 segmentation fault rustc crash.rs -Cdebuginfo=2 ```

matthiaskrgr commented 9 months ago

This bisects to nightly-2022-03-16 , I suspect #94261 is the cause cc @michaelwoerister

michaelwoerister commented 9 months ago

This is probably missing an early exit for already instantiated types while dealing with generic arguments somewhere.

apiraino commented 9 months ago

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

wxie7 commented 2 weeks ago

Is the following the same, with the difference being that Single(T) is changed to T(T)?

use std::marker::PhantomData;
struct Digit<T> {
    elem: T,
}
struct Node<T: 'static> {
    m: PhantomData<&'static T>,
}
enum FingerTree<T: 'static> {
    T(T),
    Deep(Digit<T>, Node<FingerTree<Node<T>>>),
}
enum Wrapper<T: 'static> {
    Simple,
    Other(FingerTree<T>),
}
fn main() {
    let w = Some(Wrapper::Simple::<u32>);
}