Skip to content

huge memory consumption on testcase #4630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
matthiaskrgr opened this issue Oct 4, 2019 · 5 comments
Open

huge memory consumption on testcase #4630

matthiaskrgr opened this issue Oct 4, 2019 · 5 comments
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@matthiaskrgr
Copy link
Member

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)

@matthiaskrgr matthiaskrgr added the I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ label Oct 4, 2019
@flip1995
Copy link
Member

flip1995 commented Oct 5, 2019

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.

@flip1995 flip1995 closed this as completed Oct 5, 2019
@llogiq
Copy link
Contributor

llogiq commented Oct 5, 2019

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

@llogiq llogiq reopened this Oct 5, 2019
@flip1995
Copy link
Member

flip1995 commented Oct 5, 2019

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
Copy link
Contributor

llogiq commented Oct 5, 2019

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
Labels
I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants