Skip to content

rustc crashed when compiling the crafted input #81827

Closed
@ZhangZhuoSJTU

Description

@ZhangZhuoSJTU

I think this issue is more than an internal compiler error, so I report here.

I tried this code:

#![crate_name="0"]

fn r()->i{0|{#[cfg(r(0{]0

The md5 of poc.rs is: 55d1b05bebbe11b76ee62fe193bdd5ff

I expected to see this happen: normal compilation

Instead, this happened: rustc crashes

➜  playground rustc poc.rs
error: this file contains an unclosed delimiter
 --> poc.rs:3:27
  |
3 | fn r()->i{0|{#[cfg(r(0{]0
  |          -  -             ^
  |          |  |
  |          |  unclosed delimiter
  |          unclosed delimiter

error: mismatched closing delimiter: `]`
 --> poc.rs:3:24
  |
3 | fn r()->i{0|{#[cfg(r(0{]0
  |               -       -^ mismatched closing delimiter
  |               |       |
  |               |       unclosed delimiter
  |               closing delimiter possibly meant for this

error: expected one of `)` or `,`, found `{`
 --> poc.rs:3:23
  |
3 | fn r()->i{0|{#[cfg(r(0{]0
  |                       ^ expected one of `)` or `,`

[1]    14378 abort (core dumped)  rustc poc.rs

Meta

I test it on nightly, beta, and stable versions.

rustc --version --verbose:

rustc 1.51.0-nightly (23adf9fd8 2021-02-05)
binary: rustc
commit-hash: 23adf9fd843da7a3394c824b056f93151aaa40ad
commit-date: 2021-02-05
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly
LLVM version: 11.0.1

rustc 1.50.0-beta.8 (1cd030396 2021-01-20)
binary: rustc
commit-hash: 1cd0303963629f317a08e7e52162ccca7232ae7f
commit-date: 2021-01-20
host: x86_64-unknown-linux-gnu
release: 1.50.0-beta.8

rustc 1.49.0 (e1884a8e3 2020-12-29)
binary: rustc
commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca
commit-date: 2020-12-29
host: x86_64-unknown-linux-gnu
release: 1.49.0
Backtrace

➜  playground RUST_BACKTRACE=1 rustc poc.rs
error: this file contains an unclosed delimiter
 --> poc.rs:3:27
  |
3 | fn r()->i{0|{#[cfg(r(0{]0
  |          -  -             ^
  |          |  |
  |          |  unclosed delimiter
  |          unclosed delimiter

error: mismatched closing delimiter: `]`
 --> poc.rs:3:24
  |
3 | fn r()->i{0|{#[cfg(r(0{]0
  |               -       -^ mismatched closing delimiter
  |               |       |
  |               |       unclosed delimiter
  |               closing delimiter possibly meant for this

error: expected one of `)` or `,`, found `{`
 --> poc.rs:3:23
  |
3 | fn r()->i{0|{#[cfg(r(0{]0
  |                       ^ expected one of `)` or `,`

[1]    16677 abort (core dumped)  RUST_BACKTRACE=1 rustc poc.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions