Skip to content
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

Running out of RAM during compilation #62637

Closed
optimalstrategy opened this issue Jul 12, 2019 · 1 comment
Closed

Running out of RAM during compilation #62637

optimalstrategy opened this issue Jul 12, 2019 · 1 comment
Labels
C-bug Category: This is a bug. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@optimalstrategy
Copy link

Hi

Incorrectly closing the parentheses around an if expression causes the compiler to be stuck in endless recursion (probably), causing the computer to run out of memory.

I encountered this bug while trying to return Some(if cond { ... } else { ... }) from a function by accidentally placing the left parenthesis right after the if condition: Some(if ...) { } else { }.

The code below is the minimal example I came up with that reproduces the bug. Please run it carefully since it rapidly consumes RAM (2 GB/s on my machine).

// t.rs
fn main() { 
   (if true)
}

Compiler output:

$ rustc t.rs
error: expected `{`, found `)`
 --> t.rs:2:13
  |
2 |     (if true)
  |      --     ^ expected `{`
  |      |
  |      this `if` statement has a condition, but no block

error: expected expression, found `<eof>`
 --> t.rs:3:1
  |
3 | }
  | ^ expected expression   # at this point the compiler is stuck
^C

Meta

The bug is present in both available for me compilers:

$ rustc --version --verbose
rustc 1.37.0-nightly (7840a0b75 2019-05-31)
binary: rustc
commit-hash: 7840a0b753a065a41999f1fb6028f67d33e3fdd5
commit-date: 2019-05-31
host: x86_64-unknown-linux-gnu
release: 1.37.0-nightly
LLVM version: 8.0

and

$ rustc --version --verbose
rustc 1.35.0 (3c235d560 2019-05-20)
binary: rustc
commit-hash: 3c235d5600393dfe6c36eeed34042efad8d4f26e
commit-date: 2019-05-20
host: x86_64-unknown-linux-gnu
release: 1.35.0
LLVM version: 8.0

My OS is Arch Linux 5.1.11-arch1-1-ARCH.

@estebank estebank added C-bug Category: This is a bug. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 13, 2019
@estebank
Copy link
Contributor

estebank commented Jul 13, 2019

Thank you for filing the ticket! I'm closing this as duplicate of #61858. #62607 is already out to fix it. Don't know if we will have a stable point release due to this but it seems likely that we will.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants