Skip to content

Compiler panics when disk is full #115298

Description

@DemiMarie

When compiling my project, the disk filled up and I got:

thread 'rustc' panicked at 'assertion failed: pos.get() <= self.position()', compiler/rustc_metadata/src/rmeta/encoder.rs:447:9

I’m assuming this is a compiler bug, if only because the error message is not helpful. I haven’t included an example because I don’t think the specific code being compiled matters here.

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 27, 2023
  2. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Aug 28, 2023
  3. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    C-bugCategory: This is a bug.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Aug 29, 2023
  4. leikang123 commented on Aug 30, 2023

    @leikang123
  5. ChrisDenton commented on Aug 30, 2023

    @ChrisDenton
    Member

    Posting a wall of AI generated text is very unhelpful here. Please refrain from doing so in the future.

  6. saethlin commented on Sep 4, 2023

    @saethlin
    Member

    This ICE has been reported at least 9 times now; the issues above contain a total of 7 reports, then there's this issue and @kpreid posted about running into this on the community Discord.

    I do not know why we've seen a recent uptick in reports of this ICE, but as far as I can tell the root cause is this PR (which predates all the reports): #94732, which subtly changes the API of Encoder. All writes are infallible but do not necessarily update the encoder position and thus any assertion which is based on inspecting the encoder position will explode if an encoder encounters an IO error.

    It looks to me like this tripping hazard wasn't noticed at the time, which is hardly surprising considering that this is along an error path and all the reports we have will result in unsuccessful compilation even if the assertion isn't tripped.

    I am going to try to make this not ICE anymore. The current implementation of FileEncoder has a reimplementation of BufWriter woven together with the delayed error handling; in its current state I have little confidence in my ability to review a fix that just adds updates to the encoder position so I'm going to try to untangle the logic first.

  7. self-assigned this
    on Sep 4, 2023
  8. added a commit that references this issue on Sep 11, 2023
  9. added a commit that references this issue on Sep 20, 2023
  10. felipelalli commented on Sep 21, 2023

    @felipelalli

    It might be good, in addition to fixing this specific error, for the compiler to estimate a "safe" disk space requirement before starting its operations. It could at least issue a warning before initiating or completely fail and proceed only if the user decides to force it.

    It could also issue a warning at the end of a compilation when disk space is running low, something like:

    "WARN: Low disk space, this may affect future compilations."

  11. saethlin commented on Sep 21, 2023

    @saethlin
    Member

    You're welcome to open a feature request issue for this.

    I do not think we can do such estimation accurately enough to have an acceptable false positive rate, so I suspect we would get reports of the warning firing when it shouldn't when people compile on systems with a small disk. If we actually issue such a thing as a warning, we will probably break a lot of CI that uses -Dwarnings due to estimation error.

  12. felipelalli commented on Sep 21, 2023

    @felipelalli

    You're welcome to open a feature request issue for this.

    I do not think we can do such estimation accurately enough to have an acceptable false positive rate, so I suspect we would get reports of the warning firing when it shouldn't when people compile on systems with a small disk. If we actually issue such a thing as a warning, we will probably break a lot of CI that uses -Dwarnings due to estimation error.

    Well, I suggested it. As expected, the idea was poorly received. Here is the link for record and cross-reference: Check disk space before compilation.

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

Metadata

Metadata

Assignees

Labels

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.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions