Skip to content

-Znext-solver=coherence: stack overflow #119905

@matthiaskrgr

Description

@matthiaskrgr

Code

#![recursion_limit="1024"]
#![allow(dead_code)]

use std::mem;

pub struct S0<T>(T,T);
pub struct S1<T>(Option<Box<S0<S0<T>>>>,Option<Box<S0<S0<S1<S1<T>>>>>>);
pub struct S2<T>(Option<Box<T>>,Option<S3<T>>);
pub struct S3<T>(S5<T>,Option<Box<S2<S2<T>>>>);
pub struct S4<T>(Option<Box<S3<S3<T>>>>,Option<Box<S3<S3<T>>>>);
pub struct S5<T>(Option<Box<S4<S4<T>>>>,Option<Box<S4<S4<T>>>>,Option<T>);

trait Foo { fn xxx(&self); }
/// some local of #[fundamental] trait
trait Bar {}

impl<T> Foo for T where T: Sync, T: Bar {
    fn xxx(&self) {}
}

impl Foo for S5<u8> { fn xxx(&self) {} }

fn main() {
    let s = S5(None,None,None);
    s.xxx();
    assert_eq!(mem::size_of_val(&s.2), mem::size_of::<Option<u8>>());
}

Meta

rustc --version --verbose:

rustc 1.77.0-nightly (ce1f2ccf5 2024-01-12)
binary: rustc
commit-hash: ce1f2ccf5a5ac9343623bd115a05e4151d93af0d
commit-date: 2024-01-12
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Error output

<output>
Backtrace

error: rustc interrupted by SIGSEGV, printing backtrace

/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-b35442033d0dc6f2.so(+0x2d6cc16)[0x7f1df876cc16]
/usr/lib/libc.so.6(+0x3e710)[0x7f1df585c710]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-b35442033d0dc6f2.so(+0x37dff57)[0x7f1df91dff57]

### cycle encountered after 3 frames with period 6
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-b35442033d0dc6f2.so(+0x378a11c)[0x7f1df918a11c]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-b35442033d0dc6f2.so(+0x379b388)[0x7f1df919b388]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-b35442033d0dc6f2.so(+0x37e05ec)[0x7f1df91e05ec]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-b35442033d0dc6f2.so(+0x378a11c)[0x7f1df918a11c]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-b35442033d0dc6f2.so(+0x379b388)[0x7f1df919b388]
/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-b35442033d0dc6f2.so(+0x37e05ec)[0x7f1df91e05ec]
### recursed 42 times

/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/librustc_driver-b35442033d0dc6f2.so(+0x378a11c)[0x7f1df918a11c]

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
[1]    3560606 segmentation fault  rustc ff1f66b05db64ab43484975ddfc23cfa38b36db7.rs -Znext-solver=coherence

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions