-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call 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.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Description
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
osa1
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call 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.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
ZhangZhuoSJTU commentedon Feb 6, 2021
I am not sure whether it is a security-oriented bug. If so, please close this.
But I guess it is ok to be public.
Thanks.
nagisa commentedon Feb 6, 2021
This is an explicit
process::abort
:So just an ICE, just somebody used an
process::abort
instead of abug!()
.nagisa commentedon Feb 6, 2021
rust/compiler/rustc_ast/src/mut_visit.rs
Lines 303 to 304 in 9a1d617
is the
process::abort
that's being executed.nagisa commentedon Feb 7, 2021
The problem is that the
cfg
parsing code is attempting to emit a fatal error, but error emission cannot happen through thevisit_clobber
function.The stack looks something like this:
Two potential fixes here: adjust
visit_clobber
so that it does not abort on panics or make anything running within thevisit_clobber
incapable of panicking. The latter is way harder and more prone to eventually break again.I think this is probably P-medium or thereabouts.
osa1 commentedon Feb 7, 2021
It seems like the implementation of
visit_clobber
is copied fromtake_mut
'stake
: https://github.com/Sgeo/take_mut/blob/1bd70d842c6febcd16ec1fe3a954a84032b89f52/src/lib.rs#L31-L41osa1 commentedon Feb 7, 2021
Would this be safe? My understanding is if the callback panics then the pointer will potentially be in an inconsistent state and continuing execution will not be safe.
nagisa commentedon Feb 7, 2021
Well, not in the exact form it is now, but there are a couple avenues that could be explored to make it more resilient to closure panics – e.g. one could replace the old value with some sort of placeholder default while the original value is being processed.
ZhangZhuoSJTU commentedon Feb 10, 2021
Another test-case. Hope it can help.
Playground.
apiraino commentedon Feb 10, 2021
Assigning
P-high
as discussed as part of the Prioritization Working Group procedure and removingI-prioritize
.Alexendoo commentedon Dec 31, 2021
No longer crashes due to #91519
Add regression test for rust-lang#81827
Rollup merge of rust-lang#97220 - JohnTitor:issue-81827, r=compiler-e…