Skip to content

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

Closed
@ojeda

Description

@ojeda
Contributor

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)).

Activity

added
C-bugCategory: This is a bug.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Mar 19, 2024
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Mar 19, 2024
added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
and removed
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Mar 19, 2024
GuillaumeGomez

GuillaumeGomez commented on Mar 21, 2024

@GuillaumeGomez
Member

Wow. That's... a lot. ^^'

Should be doable with a tempfile. Taking a look.

ojeda

ojeda commented on Mar 21, 2024

@ojeda
ContributorAuthor

Thanks Guillaume!

added a commit that references this issue on Mar 24, 2024

Rollup merge of rust-lang#122840 - GuillaumeGomez:rustdoc-test-too-ma…

73038c0

25 remaining items

Loading
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.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

      Participants

      @ojeda@GuillaumeGomez@jieyouxu@rustbot

      Issue actions

        ICE: `rustdoc`'s `--test` option may call `rustc` with too many arguments · Issue #122722 · rust-lang/rust