Skip to content

stack overflow during debuginfo generation #121538

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

Closed
matthiaskrgr opened this issue Feb 24, 2024 · 4 comments · Fixed by #138599
Closed

stack overflow during debuginfo generation #121538

matthiaskrgr opened this issue Feb 24, 2024 · 4 comments · Fixed by #138599
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

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 matthiaskrgr added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. labels Feb 24, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 24, 2024
@matthiaskrgr
Copy link
Member Author

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

@matthiaskrgr matthiaskrgr added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Feb 24, 2024
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Feb 24, 2024
@saethlin saethlin added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 25, 2024
@michaelwoerister michaelwoerister self-assigned this Feb 26, 2024
@michaelwoerister
Copy link
Member

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

@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 26, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 19, 2024
@wxie7
Copy link

wxie7 commented Nov 9, 2024

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>);
}

@matthiaskrgr matthiaskrgr marked this as a duplicate of #133920 Dec 5, 2024
@bors bors closed this as completed in 68b439c Apr 18, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 18, 2025
Rollup merge of rust-lang#138599 - adwinwhite:recursive-overflow, r=wesleywiser

avoid overflow when generating debuginfo for expanding recursive types

Fixes rust-lang#135093
Fixes rust-lang#121538
Fixes rust-lang#107362
Fixes rust-lang#100618
Fixes rust-lang#115994

The overflow happens because expanding recursive types keep creating new nested types when recurring into sub fields.
I fixed that by returning an empty stub node when expanding recursion is detected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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.

6 participants