Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
olegnn opened this issue Dec 8, 2019 · 5 comments · Fixed by #69175
Assignees
Labels
A-async-await Area: Async & Await A-coroutines Area: Coroutines A-frontend Area: Compiler frontend (errors, parsing and HIR) A-HIR Area: The high-level intermediate representation (HIR) AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. F-coroutines `#![feature(coroutines)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@olegnn
Copy link
Contributor

olegnn commented Dec 8, 2019

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`.
@jonas-schievink jonas-schievink added A-async-await Area: Async & Await A-coroutines Area: Coroutines C-bug Category: This is a bug. F-coroutines `#![feature(coroutines)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-frontend Area: Compiler frontend (errors, parsing and HIR) I-nominated A-HIR Area: The high-level intermediate representation (HIR) labels Dec 8, 2019
@nikomatsakis nikomatsakis added AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. P-medium Medium priority and removed I-nominated labels Dec 10, 2019
@nikomatsakis
Copy link
Contributor

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

Note that yield is unstable.

@Centril Centril added the requires-nightly This issue requires a nightly compiler in some way. label Dec 11, 2019
@estebank estebank removed the requires-nightly This issue requires a nightly compiler in some way. label Dec 11, 2019
@estebank
Copy link
Contributor

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

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 18, 2019
@chrissimpkins
Copy link
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`.

@jonas-schievink jonas-schievink added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Feb 10, 2020
@nikomatsakis
Copy link
Contributor

nikomatsakis commented Feb 14, 2020

@chrissimpkins thanks for the bisection!

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

@nikomatsakis
Copy link
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).

@estebank estebank self-assigned this Feb 15, 2020
Centril added a commit to Centril/rust that referenced this issue Feb 17, 2020
Do not ICE when encountering `yield` inside `async` block

Fix rust-lang#67158.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Feb 17, 2020
Do not ICE when encountering `yield` inside `async` block

Fix rust-lang#67158.
JohnTitor added a commit to JohnTitor/rust that referenced this issue Feb 18, 2020
Do not ICE when encountering `yield` inside `async` block

Fix rust-lang#67158.
@bors bors closed this as completed in 35e7c78 Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-coroutines Area: Coroutines A-frontend Area: Compiler frontend (errors, parsing and HIR) A-HIR Area: The high-level intermediate representation (HIR) AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. F-coroutines `#![feature(coroutines)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants