Skip to content

rustc compiler crashed when using async in loop #67893

New issue

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

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

Already on GitHub? # to your account

Closed
fbucek opened this issue Jan 5, 2020 · 9 comments · Fixed by #71182
Closed

rustc compiler crashed when using async in loop #67893

fbucek opened this issue Jan 5, 2020 · 9 comments · Fixed by #71182
Labels
A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fbucek
Copy link

fbucek commented Jan 5, 2020

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
@Centril Centril added A-async-await Area: Async & Await 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. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Jan 5, 2020
@Centril
Copy link
Contributor

Centril commented Jan 5, 2020

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

@fbucek
Copy link
Author

fbucek commented Jan 5, 2020

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.

@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Jan 5, 2020
@tmandry tmandry added AsyncAwait-OnDeck AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. labels Jan 7, 2020
@tmandry
Copy link
Member

tmandry commented Jan 7, 2020

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

@gilescope
Copy link
Contributor

Can repro. Will try and min.

@gilescope
Copy link
Contributor

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

@tmandry tmandry added the P-high High priority label Mar 3, 2020
@Aaron1011
Copy link
Member

This no longer ICEs on the latest nightly.

@Centril Centril added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 15, 2020
@Centril
Copy link
Contributor

Centril commented Mar 15, 2020

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

@rustbot ping cleanup

@rustbot rustbot added the ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections label Mar 15, 2020
@rustbot
Copy link
Collaborator

rustbot commented Mar 15, 2020

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

@steffahn
Copy link
Member

I’ve 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.

@JohnTitor JohnTitor removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Apr 16, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 16, 2020
…Simulacrum

Add some regression tests

Closes rust-lang#24843
Closes rust-lang#28575
Closes rust-lang#54067
Closes rust-lang#67893
Closes rust-lang#68813

I'm not sure who's the best person to ask to review since Centril is taking a break now.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 16, 2020
…Simulacrum

Add some regression tests

Closes rust-lang#24843
Closes rust-lang#28575
Closes rust-lang#54067
Closes rust-lang#67893
Closes rust-lang#68813

I'm not sure who's the best person to ask to review since Centril is taking a break now.
@bors bors closed this as completed in b347097 Apr 17, 2020
@tmandry tmandry moved this to Done in wg-async work Dec 8, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-async-await Area: Async & Await AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

9 participants