Skip to content

rustc runs out of memory when compiling an if statement with no block, enclosed in parentheses #61858

Closed
@kuretchi

Description

@kuretchi

I tried this code:

fn main() {
    (if foobar)
}
$ ulimit -v 2000000  # 2 GB
$ rustc main.rs

rustc first outputs some error messages and then hangs up trying to allocate a large amount of memory.

error: expected `{`, found `)`
 --> main.rs:2:15
  |
2 |     (if foobar)
  |      --       ^ expected `{`
  |      |
  |      this `if` statement has a condition, but no block

error: expected expression, found `<eof>`
 --> main.rs:3:1
  |
3 | }
  | ^ expected expression

memory allocation of 1610612736 bytes failedAborted (core dumped)

Playground

Meta

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

Metadata

Metadata

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.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions