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

Activity

hellow554

hellow554 commented on Sep 6, 2021

@hellow554
Contributor

Looks like a dup of #87932, but I'm not sure yet

Asapin

Asapin commented on Sep 6, 2021

@Asapin
Author

Yes, it does look very similar. Which is weird as I have almost identical to #87932 code in another place, except the amount of enums and structs inside the fn deserialize (2 enums and 4 structs to be precise), and it doesn't cause any errors.

tmiasko

tmiasko commented on Jan 14, 2022

@tmiasko
Contributor

Fixed in #89738.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @hellow554@Asapin@tmiasko

        Issue actions

          Stack overflow inside rustc_middle::ty::print::Printer · Issue #88664 · rust-lang/rust