Skip to content

Hang and unbounded memory consumption on invalid Cargo.toml #15778

@kpreid

Description

@kpreid

Problem

When parsing an erroneous Cargo.toml consisting solely of the character ")" (and other possible cases, but this is the minimal one), Cargo commands including cargo metadata and cargo clean will rapidly consume increasing amounts of memory until killed.

The original situation in which I encountered this bug was from git merge conflict markers.

Steps

mkdir oom
cd oom
echo ')' > Cargo.toml
cargo +nightly metadata
^C

Version

$ cargo +nightly version --verbose
cargo 1.90.0-nightly (9b296973b 2025-07-25)
release: 1.90.0-nightly
commit-hash: 9b296973b425ffb159e12cf3cd56580fd5c85382
commit-date: 2025-07-25
host: aarch64-apple-darwin
libgit2: 1.9.1 (sys:0.20.2 vendored)
libcurl: 8.7.1 (sys:0.4.82+curl-8.14.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 3.5.0 8 Apr 2025
os: Mac OS 15.5.0 [64-bit]

This happens on current (and somewhat older) nightly but not on current beta or stable 1.88.0.

@rustbot label +regression-from-stable-to-nightly

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewregression-from-stable-to-nightlyRegression in nightly that previously worked in stable.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions