Skip to content

rustc unexpectedly overflowed its stack! (Nested Datatypes) #115994

Closed
@cutthroat

Description

@cutthroat

Code

// To prevent "overflow while adding drop-check rules".
use std::mem::ManuallyDrop;

pub enum Foo<U> {
    Leaf(U),

    Branch(BoxedFoo<BoxedFoo<U>>),
}

pub type BoxedFoo<U> = ManuallyDrop<Box<Foo<U>>>;

pub fn test() -> Foo<usize> {
    todo!()
}

Meta

rustc --version --verbose:

rustc 1.74.0-nightly (65ea825f4 2023-09-18)
binary: rustc
commit-hash: 65ea825f4021eaf77f1b25139969712d65b435a4
commit-date: 2023-09-18
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0

Error output

error: rustc interrupted by SIGSEGV, printing backtrace
Backtrace

<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(+0x3154476)[0x7fc55fbb1476]
/usr/lib/libc.so.6(+0x3e710)[0x7fc55c679710]
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(_RNvNtNtCsgKY0QmBZTTg_17rustc_codegen_ssa9debuginfo10type_names14push_item_name+0x14)[0x7fc55de39434]
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(_RNvNtNtCsgKY0QmBZTTg_17rustc_codegen_ssa9debuginfo10type_names14push_item_name+0x201)[0x7fc55de39621]
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(_RNvNtNtCsgKY0QmBZTTg_17rustc_codegen_ssa9debuginfo10type_names14push_item_name+0x201)[0x7fc55de39621]
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(_RNvNtNtCsgKY0QmBZTTg_17rustc_codegen_ssa9debuginfo10type_names14push_item_name+0x201)[0x7fc55de39621]
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(+0x13d7aab)[0x7fc55de34aab]

### cycle encountered after 7 frames with period 8
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(+0x13dde4c)[0x7fc55de3ae4c]
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(+0x13dde4c)[0x7fc55de3ae4c]
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(+0x13dde4c)[0x7fc55de3ae4c]
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(+0x13dde4c)[0x7fc55de3ae4c]
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(+0x13dde4c)[0x7fc55de3ae4c]
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(+0x13dde4c)[0x7fc55de3ae4c]
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(+0x13dde4c)[0x7fc55de3ae4c]
<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(+0x13dde4c)[0x7fc55de3ae4c]
### recursed 31 times

<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-8e42d501a7efdfb9.so(+0x13dde4c)[0x7fc55de3ae4c]

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
error: could not compile `rustc-bug` (lib)

Caused by:
  process didn't exit successfully: `<redacted>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name rustc_bug --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=190 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=b16d58bd391752b1 -C extra-filename=-b16d58bd391752b1 --out-dir <redacted>/rustc-bug/target/debug/deps -C incremental=<redacted>/rustc-bug/target/debug/incremental -L dependency=<redacted>/rustc-bug/target/debug/deps` (signal: 11, SIGSEGV: invalid memory reference)

Edit: Simplified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions