Skip to content

ICE on beta and nightly as result of use of yield in combination with macro call in async block #67158

@olegnn

Description

@olegnn
Contributor

This code

fn main() {
    async { yield print!(":C") };
}

(Playground)

produces ICE on current beta and nightly

thread 'rustc' panicked at 'src/librustc/hir/map/hir_id_validator.rs:26: 
ItemLocalIds not assigned densely in ::main[0]. Max ItemLocalId = 14, missing IDs = ["[local_id: 1, node:unknown node (hir_id=HirId { owner: DefIndex(12), local_id: 1 })]"]; seens IDs = ["(HirId { owner: DefIndex(12), local_id: 0 } fn main (hir_id=HirId { owner: DefIndex(12), local_id: 0 }))", "(HirId { owner: DefIndex(12), local_id: 13 } block { ::std::future::from_generator(|| { (/*ERROR*/) }); } (hir_id=HirId { owner: DefIndex(12), local_id: 13 }))", "(HirId { owner: DefIndex(12), local_id: 10 } expr ::std::future::from_generator (hir_id=HirId { owner: DefIndex(12), local_id: 10 }))", "(HirId { owner: DefIndex(12), local_id: 7 } path segment std (hir_id=HirId { owner: DefIndex(12), local_id: 7 }))", "(HirId { owner: DefIndex(12), local_id: 4 } expr { (/*ERROR*/) } (hir_id=HirId { owner: DefIndex(12), local_id: 4 }))", "(HirId { owner: DefIndex(12), local_id: 14 } expr { ::std::future::from_generator(|| { (/*ERROR*/) }); } (hir_id=HirId { owner: DefIndex(12), local_id: 14 }))", "(HirId { owner: DefIndex(12), local_id: 11 } expr ::std::future::from_generator(|| { (/*ERROR*/) }) (hir_id=HirId { owner: DefIndex(12), local_id: 11 }))", "(HirId { owner: DefIndex(12), local_id: 8 } path segment future (hir_id=HirId { owner: DefIndex(12), local_id: 8 }))", "(HirId { owner: DefIndex(12), local_id: 5 } expr || { (/*ERROR*/) } (hir_id=HirId { owner: DefIndex(12), local_id: 5 }))", "(HirId { owner: DefIndex(12), local_id: 2 } expr (/*ERROR*/) (hir_id=HirId { owner: DefIndex(12), local_id: 2 }))", "(HirId { owner: DefIndex(12), local_id: 12 } stmt ::std::future::from_generator(|| { (/*ERROR*/) }); (hir_id=HirId { owner: DefIndex(12), local_id: 12 }))", "(HirId { owner: DefIndex(12), local_id: 9 } path segment from_generator (hir_id=HirId { owner: DefIndex(12), local_id: 9 }))", "(HirId { owner: DefIndex(12), local_id: 6 } path segment  (hir_id=HirId { owner: DefIndex(12), local_id: 6 }))", "(HirId { owner: DefIndex(12), local_id: 3 } block { (/*ERROR*/) } (hir_id=HirId { owner: DefIndex(12), local_id: 3 }))"]', src/librustc/util/bug.rs:37:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.40.0-beta.2 (2a0ba54fa 2019-11-16) running on x86_64-apple-darwin

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
error: could not compile `rust-games`.

Activity

added
C-bugCategory: This is a bug.
F-coroutines`#![feature(coroutines)]`
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
A-frontendArea: Compiler frontend (errors, parsing and HIR)
A-HIRArea: The high-level intermediate representation (HIR)
on Dec 8, 2019
added
AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.
and removed on Dec 10, 2019
nikomatsakis

nikomatsakis commented on Dec 10, 2019

@nikomatsakis
Contributor

Tagging as P-medium and "triaged" for async-await.

Note that yield is unstable.

removed
requires-nightlyThis issue requires a nightly compiler in some way.
on Dec 11, 2019
estebank

estebank commented on Dec 11, 2019

@estebank
Contributor

@Centril the feature is nightly but the ice doesn't require any feature gate to trigger.

chrissimpkins

chrissimpkins commented on Feb 10, 2020

@chrissimpkins
Member

Regression found in the compiler

searched nightlies: from nightly-2019-01-01 to nightly-2020-02-01
regressed nightly: nightly-2019-09-29
searched commits: from 084beb8 to 488381c
regressed commit: f3c8eba
source code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=956b959a5649adaecb4fe39acef8239d

Instructions

cargo bisect-rustc --start 2019-09-28 --end 2019-09-29 --prompt

Error

COLLAPSIBLE ERROR STACKTRACE

error[E0658]: yield syntax is experimental
 --> src/main.rs:2:13
  |
2 |     async { yield print!(":C") };
  |             ^^^^^^^^^^^^^^^^^^
  |
  = note: for more information, see https://github.com/rust-lang/rust/issues/43122
  = help: add `#![feature(generators)]` to the crate attributes to enable

error[E0727]: `async` generators are not yet supported
 --> src/main.rs:2:13
  |
2 |     async { yield print!(":C") };
  |             ^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'src/librustc/hir/map/hir_id_validator.rs:27: 
ItemLocalIds not assigned densely in ::main[0]. Max ItemLocalId = 14, missing IDs = ["[local_id: 1, node:unknown node (hir_id=HirId { owner: DefIndex(3), local_id: 1 })]"]; seens IDs = ["(HirId { owner: DefIndex(3), local_id: 0 } fn main (hir_id=HirId { owner: DefIndex(3), local_id: 0 }))", "(HirId { owner: DefIndex(3), local_id: 13 } block { ::std::future::from_generator(|| { (/*ERROR*/) }); } (hir_id=HirId { owner: DefIndex(3), local_id: 13 }))", "(HirId { owner: DefIndex(3), local_id: 10 } expr ::std::future::from_generator (hir_id=HirId { owner: DefIndex(3), local_id: 10 }))", "(HirId { owner: DefIndex(3), local_id: 7 } path segment std (hir_id=HirId { owner: DefIndex(3), local_id: 7 }))", "(HirId { owner: DefIndex(3), local_id: 4 } expr { (/*ERROR*/) } (hir_id=HirId { owner: DefIndex(3), local_id: 4 }))", "(HirId { owner: DefIndex(3), local_id: 14 } expr { ::std::future::from_generator(|| { (/*ERROR*/) }); } (hir_id=HirId { owner: DefIndex(3), local_id: 14 }))", "(HirId { owner: DefIndex(3), local_id: 11 } expr ::std::future::from_generator(|| { (/*ERROR*/) }) (hir_id=HirId { owner: DefIndex(3), local_id: 11 }))", "(HirId { owner: DefIndex(3), local_id: 8 } path segment future (hir_id=HirId { owner: DefIndex(3), local_id: 8 }))", "(HirId { owner: DefIndex(3), local_id: 5 } expr || { (/*ERROR*/) } (hir_id=HirId { owner: DefIndex(3), local_id: 5 }))", "(HirId { owner: DefIndex(3), local_id: 2 } expr (/*ERROR*/) (hir_id=HirId { owner: DefIndex(3), local_id: 2 }))", "(HirId { owner: DefIndex(3), local_id: 12 } stmt ::std::future::from_generator(|| { (/*ERROR*/) }); (hir_id=HirId { owner: DefIndex(3), local_id: 12 }))", "(HirId { owner: DefIndex(3), local_id: 9 } path segment from_generator (hir_id=HirId { owner: DefIndex(3), local_id: 9 }))", "(HirId { owner: DefIndex(3), local_id: 6 } path segment  (hir_id=HirId { owner: DefIndex(3), local_id: 6 }))", "(HirId { owner: DefIndex(3), local_id: 3 } block { (/*ERROR*/) } (hir_id=HirId { owner: DefIndex(3), local_id: 3 }))"]', src/librustc/util/bug.rs:37:26
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1052
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1428
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
  12: std::panicking::begin_panic
  13: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  14: rustc::ty::context::tls::with_opt::{{closure}}
  15: rustc::ty::context::tls::with_opt
  16: rustc::util::bug::opt_span_bug_fmt
  17: rustc::util::bug::bug_fmt
  18: rustc::hir::map::hir_id_validator::check_crate
  19: rustc_session::utils::<impl rustc_session::session::Session>::time
  20: rustc::hir::map::map_crate
  21: rustc_interface::passes::create_global_ctxt
  22: rustc_interface::queries::Queries::global_ctxt
  23: rustc_interface::interface::run_compiler_in_existing_thread_pool
  24: scoped_tls::ScopedKey<T>::set
  25: syntax::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.43.0-nightly (58b834344 2020-02-05) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0658, E0727.
For more information about an error, try `rustc --explain E0658`.

nikomatsakis

nikomatsakis commented on Feb 14, 2020

@nikomatsakis
Contributor

@chrissimpkins thanks for the bisection!

Annoyingly, it regressed in a rollup PR, which means there are many candidates:

nikomatsakis

nikomatsakis commented on Feb 14, 2020

@nikomatsakis
Contributor

If I had to guess, I would guess #64830 (cc @estebank) triggered this regression, but #64859 or #64802 are possibilities. I would guess #64830 because it caused the compiler to keep compiling when it might've aborted, and maybe it would've aborted in these cases and hence never reached the code that causes an ICE.

If indeed I am correct, then this could be fixed by adding a delay_span_bug call at the point of the ICE (i.e., basically asserting that some error has occurred but otherwise just try to not crash).

self-assigned this
on Feb 15, 2020
added a commit that references this issue on Feb 17, 2020
323f5bb
added a commit that references this issue on Feb 17, 2020
5ba1dd7
added 2 commits that reference this issue on Feb 18, 2020
cdaeb23
35e7c78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-HIRArea: The high-level intermediate representation (HIR)A-async-awaitArea: Async & AwaitA-coroutinesArea: CoroutinesA-frontendArea: Compiler frontend (errors, parsing and HIR)AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.F-coroutines`#![feature(coroutines)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.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

    Participants

    @nikomatsakis@Centril@estebank@jonas-schievink@chrissimpkins

    Issue actions

      ICE on beta and nightly as result of use of `yield` in combination with macro call in `async` block · Issue #67158 · rust-lang/rust