Skip to content

huge memory consumption on testcase #4630

Open
@matthiaskrgr

Description

@matthiaskrgr

cc #3142
This was found by running clippy on glacier https://github.com/rust-lang/glacier
./fixed/23600.rs

static V1: [u8; 0xffff_ffff] = [0u8; 0xffff_ffff];
fn main() { V1[0]; }

seems to want to consume all of the systems run when checked with clippy.

clippy 0.0.212 (648e5b9 2019-10-01)

Activity

added
I-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
on Oct 4, 2019
flip1995

flip1995 commented on Oct 5, 2019

@flip1995
Member

Clippy just uses a few MBs more than just running rustc main.rs on this file. Same behavior with cargo check. I don't think that this is a bug, since this allocates a static array of 4GB. Since statics are written in the BSS segment of a program this is quiet expected.

The resulting size of the binary should also be about 4GB.


rustc main.rs also got killed on my OS.

llogiq

llogiq commented on Oct 5, 2019

@llogiq
Contributor

We could perhaps solve this by extending clippy_lints/src/const.rs so that the static perhaps doesn't even get instantiated.

reopened this on Oct 5, 2019
flip1995

flip1995 commented on Oct 5, 2019

@flip1995
Member

cargo check also allocates these statics, so the only way to prevent an allocation like this is to stop the compilation / check before rustc allocates the static (I don't know at which step this happens). Otherwise we would have to include something in Clippy, that changes basic behavior of rustc (allocation of statics), which I don't think we should do.

That being said, maybe we can change the behavior of cargo-check to not allocate statics. But then again, I can imagine, that MIR relies on these allocations, for optimizations, const propagation or similar things. This would mean, that we need to change the behavior of rustc.

All in all, I don't think Clippy is the right place to take care of this.

llogiq

llogiq commented on Oct 5, 2019

@llogiq
Contributor

I agree that we're not exactly going to fix the issue. We could still deny-lint it before MIR gets to see it.

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

    I-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @matthiaskrgr@llogiq@flip1995

        Issue actions

          huge memory consumption on testcase · Issue #4630 · rust-lang/rust-clippy