Skip to content

ICE: rustdoc's --test option may call rustc with too many arguments #122722

Closed
@ojeda

Description

@ojeda

rustdoc's --test option may call rustc with too many arguments, e.g. due to --cfgs, ICE'ing with:

thread 'x.rs - S (line 1)' panicked at src/librustdoc/doctest.rs:407:38:
Failed to spawn rustc process: Os { code: 7, kind: ArgumentListTooLong, message: "Argument list too long" }

In particular, the original call to rustdoc (i.e. the user's call) may not suffer from this if they used @args to pass many arguments, but rustdoc will then try to spawn rustc passing them as parameters, and thus failing.

A reproducer may look like, for large enough N:

echo -e '//! ```\n//! ```' > x.rs
yes -- --cfg=A | head -n $N > cfgs
rustdoc --test @cfgs x.rs

Since different systems may have different limits, it may be best to have rustdoc use a temporary file for all arguments that come from unbounded lists. Or perhaps using the original @args, if that is possible, since users using too many e.g. --cfgs are probably using them already.

In the kernel we are close to hitting the limit: we have 28k+ --cfgs arguments in big configurations, and we may start soon passing --check-cfgs for those too. Passing our @cfgs twice already hits the limit.

Meta

Can be reproduced with both the latest stable (1.76.0) and the latest nightly (1.79.0-nightly (3c85e56 2024-03-18)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-rustdocRelevant to the rustdoc 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