Skip to content

Stack overflow inside rustc_middle::ty::print::Printer #88664

Closed
@Asapin

Description

@Asapin

Getting a stack overflow error even on a simple cargo check if there's too many structs inside the implementation of serde::Deserialize trait.

cargo check
    Checking err v0.1.0 (D:\projects\rust\err)

thread 'rustc' has overflowed its stack
error: could not compile `err`                                                                                                                               

Caused by:
  process didn't exit successfully: `rustc --crate-name err --edition=2018 src\main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -C metadata=9fd35313c6199767 -C extra-filename=-9fd35313c6199767 --out-dir D:\projects\rust\err\target\debug\deps -C incremental=D:\projects\rust\err\target\debug\incremental -L dependency=D:\projects\rust\err\target\debug\deps --extern serde=D:\projects\rust\err\target\debug\deps\libserde-5ecaf821eaf01989.rmeta --extern serde_json=D:\projects\rust\err\target\debug\deps\libserde_json-ec8cae54bf55cb2a.rmeta` (exit code: 0xc00000fd, STATUS_STACK_OVERFLOW)

Project to reproduce: link to playground

But if I move all temporary structs out of the fn deserialize<D> method, the error goes away: working version

Crash dump from WinDbg: ~240MB

As far as I can tell, stack overflow happens somewhere inside rustc_middle::ty::print::Printer

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions