Skip to content

Some recursive types cause infinite recursion when creating debuginfo #133920

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
wxie7 opened this issue Dec 5, 2024 · 2 comments
Closed

Some recursive types cause infinite recursion when creating debuginfo #133920

wxie7 opened this issue Dec 5, 2024 · 2 comments
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@wxie7
Copy link

wxie7 commented Dec 5, 2024

I tried this code:

rustc -C link-dead-code -C debuginfo=2  file.rs
enum Foo<T: 'static> {
    Value(T),
    Recursive(&'static Foo<Option<T>>),
}
fn main() {
    let _x = Foo::Value(());
}

Meta

rustc --version --verbose:

rustc 1.85.0-nightly (acabb5248 2024-12-04)
binary: rustc
commit-hash: acabb5248231987ae1f0c215208d1005a5db402d
commit-date: 2024-12-04
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.5
Backtrace

warning: variant `Recursive` is never constructed
 --> mutant.rs:3:5
  |
1 | enum Foo<T: 'static> {
  |      --- variant in this enum
2 |     Value(T),
3 |     Recursive(&'static Foo<Option<T>>),
  |     ^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

error: rustc interrupted by SIGSEGV, printing backtrace

/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x36d7fa3)[0x7926f32d7fa3]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7926ef842520]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(_RNvNtNtCskYQ3m3XnxIX_17rustc_codegen_ssa9debuginfo10type_names14push_item_name+0x9)[0x7926f4812b09]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(_RNvNtNtCskYQ3m3XnxIX_17rustc_codegen_ssa9debuginfo10type_names14push_item_name+0x1b3)[0x7926f4812cb3]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(_RNvNtNtCskYQ3m3XnxIX_17rustc_codegen_ssa9debuginfo10type_names14push_item_name+0x1b3)[0x7926f4812cb3]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x5198b39)[0x7926f4d98b39]

### cycle encountered after 6 frames with period 7
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x519827d)[0x7926f4d9827d]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x519827d)[0x7926f4d9827d]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x519827d)[0x7926f4d9827d]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x519827d)[0x7926f4d9827d]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x519827d)[0x7926f4d9827d]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x519827d)[0x7926f4d9827d]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x519827d)[0x7926f4d9827d]
### recursed 35 times

/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x519827d)[0x7926f4d9827d]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x519827d)[0x7926f4d9827d]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x519827d)[0x7926f4d9827d]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x519827d)[0x7926f4d9827d]
/home/xieym/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-0e1744037f1f9b04.so(+0x519827d)[0x7926f4d9827d]

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
help: you can increase rustc's stack size by setting RUST_MIN_STACK=16777216
note: backtrace dumped due to SIGSEGV! resuming signal
[1]    430090 segmentation fault (core dumped)  rustc -C link-dead-code -C debuginfo=2 mutant.rs

@wxie7 wxie7 added the C-bug Category: This is a bug. label Dec 5, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 5, 2024
@saethlin saethlin added 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. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 5, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Dec 5, 2024

This does not need -C link-dead-code, -C debuginfo=2 is sufficient to repro on a x86_64-unknown-linux-gnu host. Does not repro with only -C debuginfo=1.

@jieyouxu jieyouxu added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Dec 5, 2024
@saethlin saethlin changed the title segmentation fault Some recursive types cause infinite recursion when creating debuginfo Dec 5, 2024
@saethlin saethlin marked this as a duplicate of #133922 Dec 5, 2024
@matthiaskrgr
Copy link
Member

duplicate of #121538

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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants