-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Nested recursive enum with ManuallyDrop causes thread 'rustc' to overflow its stack #135093
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
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.
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
trying to do something similar with the example in E0320: use core::mem::ManuallyDrop;
enum A<T> {
B,
C(T, Vec<ManuallyDrop<A<T>>>)
}
fn main() {
let _ = A::<()>::B;
} both runs and compiles. |
Minimized: pub struct Wrap<T>(T);
pub enum Recursive<T> {
Recurse(*const Recursive<Wrap<T>>),
Item(T),
}
pub struct Conditional<T>(Option<Recursive<T>>);
fn main() {
let _x = Conditional::<()>(None);
} |
a bit more reduced: struct Wrap<T>(T);
enum Recursive<T> {
Recurse(*const Recursive<Wrap<T>>),
Item(T),
}
fn main() {
let _x: Recursive<()>;
} playground |
|
This is probably a duplicate of #121538 |
@rustbot claim |
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.
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
There seemed to be an issue with the type Composition<Conditional> adding drop-check rules, so I added ManuallyDrop to get the program to compile. I also added the unpin impl as there was also an error regarding its implementation.
I tried this code:
I expected wither for the program to run, or for the compiler to give the a similar error to when ManuallyDrop is removed: "overflow while adding drop-check rules for
Vec<Composition<T>>
"Instead, the rustc thread overflowed its stack.
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: