Skip to content

rustc crashes with "Aborted (core dumped)" on malformed attribute #87790

Closed
@dwrensha

Description

@dwrensha

rustc crashes ungracefully when given the following input (found by fuzz-rustc):

struct B{C:[);{#![cfg_attr(r(c:
$ rustc -vV
rustc 1.56.0-nightly (25b764849 2021-08-04)
binary: rustc
commit-hash: 25b764849625cb090e8b81d12d2bb2295d073788
commit-date: 2021-08-04
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

$ rustc bug.rs
error: this file contains an unclosed delimiter
 --> bug.rs:1:33
  |
1 | struct B{C:[);{#![cfg_attr(r(c:
  |         -     -  -        - -   ^
  |         |     |  |        | |
  |         |     |  |        | unclosed delimiter
  |         |     |  |        unclosed delimiter
  |         |     |  unclosed delimiter
  |         |     unclosed delimiter
  |         unclosed delimiter

error: expected type, found `]`
 --> bug.rs:1:13
  |
1 | struct B{C:[);{#![cfg_attr(r(c:
  |             ^ expected type

error: expected one of `.`, `?`, `]`, or an operator, found `}`
 --> bug.rs:1:33
  |
1 | struct B{C:[);{#![cfg_attr(r(c:
  |            - unclosed delimiter ^ help: `]` may belong here

error[E0658]: attributes on expressions are experimental
 --> bug.rs:1:16
  |
1 | struct B{C:[);{#![cfg_attr(r(c:
  |                ^^^^^^^^^^^^^^^^^
  |
  = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
  = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable

error: expected one of `(`, `)`, `,`, `::`, or `=`, found `:`
 --> bug.rs:1:31
  |
1 | struct B{C:[);{#![cfg_attr(r(c:
  |                               ^ expected one of `(`, `)`, `,`, `::`, or `=`

Aborted (core dumped)

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions