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

rustc compiler crashed when using async in loop #67893

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 AsyncAwait-Triaged C-bug E-needs-test I-ICE ICEBreaker-Cleanup-Crew P-high T-compiler

Comments

@fbucek
Copy link

@fbucek 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 I-ICE T-compiler E-needs-mcve labels Jan 5, 2020
@Centril
Copy link
Contributor

@Centril 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 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 label Jan 5, 2020
@tmandry tmandry added AsyncAwait-OnDeck AsyncAwait-Triaged labels Jan 7, 2020
@tmandry
Copy link
Contributor

@tmandry 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

@gilescope gilescope commented Jan 7, 2020

Can repro. Will try and min.

@gilescope
Copy link
Contributor

@gilescope gilescope commented Jan 8, 2020

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

@tmandry tmandry added this to To do in wg-async work Feb 11, 2020
@tmandry tmandry added the P-high label Mar 3, 2020
@tmandry tmandry moved this from To do to In progress in wg-async work Mar 3, 2020
@tmandry tmandry moved this from In progress to To do in wg-async work Mar 3, 2020
@Aaron1011
Copy link
Member

@Aaron1011 Aaron1011 commented Mar 14, 2020

This no longer ICEs on the latest nightly.

@Centril Centril added the E-needs-test label Mar 15, 2020
@Centril
Copy link
Contributor

@Centril 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 label Mar 15, 2020
@rustbot
Copy link
Collaborator

@rustbot 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
Contributor

@steffahn steffahn commented Apr 12, 2020

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 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.
wg-async work automation moved this from On deck to Done Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await AsyncAwait-Triaged C-bug E-needs-test I-ICE ICEBreaker-Cleanup-Crew P-high T-compiler
Projects
Development

Successfully merging a pull request may close this issue.

9 participants