rustc compiler crashed when using async in loop

Created on 5 Jan 2020  路  9Comments  路  Source: rust-lang/rust

When learning async/await feature I was struggling with running multiple tasks simultaneously.

Loop while let Some.... causes compiler to crash

https://github.com/fbucek/rust-async/blob/f6cc831c817a6b9d2f1c79182c5415b877f0da1e/actix-async/src/lib.rs#L30

Github Action crash output:

https://github.com/fbucek/rust-async/commit/f6cc831c817a6b9d2f1c79182c5415b877f0da1e/checks?check_suite_id=384856246

I expected to see this happen: Error message if something goes wrong.

Instead, this happened: Compiler crashed

Meta

Crash happens on macOS rustc 1.40 / Linux rustc 1.40 / Linux rustc 1.39 ( github actions )

rustc --version --verbose:

macOS

rustc 1.40.0 (73528e339 2019-12-16)
binary: rustc
commit-hash: 73528e339aae0f17a15ffa49a8ac608f50c6cf14
commit-date: 2019-12-16
host: x86_64-apple-darwin
release: 1.40.0
LLVM version: 9.0

Linux

rustc 1.40.0 (73528e339 2019-12-16)
binary: rustc
commit-hash: 73528e339aae0f17a15ffa49a8ac608f50c6cf14
commit-date: 2019-12-16
host: x86_64-unknown-linux-gnu
release: 1.40.0
LLVM version: 9.0
A-async-await AsyncAwait-OnDeck AsyncAwait-Triaged C-bug E-needs-test I-ICE ICEBreaker-Cleanup-Crew P-high T-compiler

All 9 comments

If you could provide an example that ICEs in e.g. the playground that would be helpful towards fixing the issue. :)

Provided example is pretty small, but it is dependent on tokio and actix-web.

I do not know how to create such an example in playground, I do know know how I can replace async tokio::sync::mpsc with standard library which does not have async alternative as far as i know.

I have tried to simplify code but then crash disappear. Just putting everything into one file main.rs and crash is gone, code wont compile and reasonable errors show up.

Visiting from triage.. we decided that as the first step we should reduce this reproducer to a more self-contained one.

Can repro. Will try and min.

Reduced version so far is here: https://github.com/gilescope/rust-async

This no longer ICEs on the latest nightly.

Let's see if we can shrink https://github.com/gilescope/rust-async further so that we can add a test.

@rustbot ping cleanup

Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
[instructions] for tackling these sorts of bugs. Maybe take a look?
Thanks! <3

cc @AminArria @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @jakevossen5 @KarlK90 @LeSeulArtichaut @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke

I鈥檝e reduced it quite a bit. Down to dependencies on std only. Appears to need 2 crates.

my_crate/src/main.rs

fn g(_: impl Send) {}

fn main() {
    g(my_crate::run())
}

my_crate/src/lib.rs

use std::sync::{Arc, Mutex};

pub async fn f(_: ()) {}

pub async fn run() {
    let x: Arc<Mutex<()>> = unimplemented!();
    f(*x.lock().unwrap()).await;
}
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
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 (73528e339 2019-12-16) 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

error: could not compile `my_crate`.

To learn more, run the command again with --verbose.
Was this page helpful?
0 / 5 - 0 ratings