Skip to content

Initializing wrapper struct private field blows up system memory. #119631

Closed
@meowjesty

Description

@meowjesty

I tried initializing a private field from a wrapper struct pub struct Foo(/*private fields*/) that is defined in another crate, and Rust started to eat all my system memory, until I was forced to restart the computer.

Unfortunately the code that caused this from my side is closed source, but I was trying to initialize the Extensions struct like this:

let extensions = Extensions(
        license
            .certificate
            .iter_extensions()
            .cloned()
            .collect::<Vec<_>>(),
    );

I expected to see this happen:

Either a compiler crash or just the compiler giving me an error saying that you can't do that!

Instead, this happened:

System memory usage kept going up and up, until it crashed my pc. Limiting cargo check memory usage just meant that the process was killed, so no error messages either.

Meta

rustc --version --verbose:

rustc 1.76.0-nightly (1fdfe1234 2023-12-06)
binary: rustc
commit-hash: 1fdfe1234795a289af1088aefa92ef80191cb611
commit-date: 2023-12-06
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5

I've also tried (and got the same results) nightly-2024-01-05.

We got this issue in 3 different systems, 2 being linux x64 and one being macos (with the m1/2 arch, whatever that is called).

Backtrace

No backtrace, rust didn't produce any error output, it just got stuck in checking {crate-name} forever.

<backtrace>

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-compilememIssue: Problems and improvements with respect to memory usage during compilation.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.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