Skip to content

Infinite loop in compiler #118163

Open
Open

Description

@wbrickner

Minimal example code which causes infinite compile times:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=13fec5b370c8046012770d2e2470c934

trait Bound { type Assoc; }

struct Recursive<'a, A: Bound> {
  value: A,
  rest: &'a Option<Recursive<'a, A::Assoc>>
}

I expected to see: the compiler finish executing.

Instead, this happened: the compiler hangs with modest CPU usage, seemingly indefinitely.

As an aside, the lack of a bound on the Assoc type should raise an error (otherwise the declaration is self-contradictory), but we never even get that far. So I have removed the bound in favor of making the example as minimal as possible. To be clear, the version with the correct bound hangs as well.

Meta

I have not done a thorough search over which versions hang.

The bug exists in stable: 1.73.0, 1.74.0, and possibly more versions of stable compiler.
The bug exists in beta 1.75.0-beta.3, and nightly 1.76.0-nightly, and possibly more versions of these compilers.

rustc --version --verbose:

rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: aarch64-apple-darwin
release: 1.73.0
LLVM version: 17.0.2

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Nov 22, 2023
  2. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Nov 22, 2023
  3. removed
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    on Nov 26, 2023
  4. veera-sivarajan commented on Mar 31, 2024

    @veera-sivarajan
    Contributor

    @rustbot assign

  5. rustbot commented on Mar 31, 2024

    @rustbot
    Collaborator

    Error: Parsing assign command in comment failed: ...' assign' | error: specify user to assign to at >| ''...

    Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

  6. veera-sivarajan commented on Mar 31, 2024

    @veera-sivarajan
    Contributor

    @rustbot claim

  7. removed their assignment
    on Jul 31, 2024
  8. wbrickner commented on Aug 5, 2024

    @wbrickner
    Author

    Bump as this bug still exists in 1.80 stable + beta + nightly compilers

  9. glingy commented on Dec 6, 2025

    @glingy

    Bump as I just hit what I think is this problem (I have similar recursive trees), and am getting infinite compile times. Same playground in original issue report is unchanged in latest 1.94.0 nightly

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

    A-trait-systemArea: Trait systemC-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.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions