Skip to content

Codegen ICE/regression with 2019-06-12 nightly when using async fn<T: Fn()>(&self, T) #61793

Closed
@Matthias247

Description

@Matthias247
Contributor

Unfortunately the error message is super thin and I can't provide the source of the project. Therefore it's also hard to provide a minimal reproducible example.

thread 'rustc' panicked at 'assertion failed: target_offset >= offset', src/librustc_codegen_llvm/type_of.rs:130:9
stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
  ...
  36: <unknown>
query stack during panic:
end of query stack

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.37.0-nightly (2887008e0 2019-06-12) 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

Some hints:

  • Yesterdays nightly (nightly-2019-06-11-x86_64-apple-darwin) doesn't ICE
  • The project makes heavy use of async/await. Therefore it might by related to that. I wondered whether it's about @tmandry's generator optimization from Generator optimization: Overlap locals that never have storage live at the same time #60187. However I also checked that out locally from their branch 2 days ago and built it myself, and it didn't crash. At that point I had all commits up to "Extract generator_layout as a method" included, only the last commit which was added later was missing.

Activity

changed the title [-]ICE/regression with todays nightly[/-] [+]Codegen ICE/regression with todays nightly[/+] on Jun 13, 2019
added
C-bugCategory: This is a bug.
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.
on Jun 13, 2019
Centril

Centril commented on Jun 13, 2019

@Centril
Contributor

@Matthias247 Could you please test your code out with debuginfo-level = 2 in config.toml (you'll need to build rustc yourself) and provide the more extensive backtrace?

Matthias247

Matthias247 commented on Jun 14, 2019

@Matthias247
ContributorAuthor

I tried running that over the afternoon. Unfortunately something went wrong:

   Compiling rustc_macros v0.1.0 (/Users/matthias/Code/rust/rust/src/librustc_macros)
error[E0460]: found possibly newer version of crate `std` which `synstructure` depends on
 --> src/librustc_macros/src/lib.rs:6:5
  |
6 | use synstructure::decl_derive;
  |     ^^^^^^^^^^^^
  |
  = note: perhaps that crate needs to be recompiled?
  = note: the following crate versions were found:
          crate `std`: /Users/matthias/Code/rust/rust/build/x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib/libstd-5ab454490186c8f5.rlib
          crate `std`: /Users/matthias/Code/rust/rust/build/x86_64-apple-darwin/stage1/lib/rustlib/x86_64-apple-darwin/lib/libstd-5ab454490186c8f5.dylib
          crate `synstructure`: /Users/matthias/Code/rust/rust/build/x86_64-apple-darwin/stage1-rustc/release/deps/libsynstructure-7d32b126cebc2b54.rlib

error: aborting due to previous error

error: Could not compile `rustc_macros`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Unfortunately that happened after around 1.5 hours of compilation. This machine here is definitely too slow for doing any reasonable rustc compilation :'(

Matthias247

Matthias247 commented on Jun 14, 2019

@Matthias247
ContributorAuthor

Got it running by deleting enough libraries and rebuilding. Unfortunately it just prints exactly the same error message. I think the setting might already had been enabled as far as I can derive from the compiler output above:

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

changed the title [-]Codegen ICE/regression with todays nightly[/-] [+]Codegen ICE/regression with todays nightly when using async fn<T: Fn()>(&self, T)[/+] on Jun 14, 2019
Matthias247

Matthias247 commented on Jun 14, 2019

@Matthias247
ContributorAuthor

I played around with my code and deleted stuff until I got a simple repro:

#![feature(async_await)]

struct Foo {
}

impl Foo {
    pub async fn do_foo<F: Fn()>(&self, _f: F) {
    }
}

async fn x() {
    let foo = Foo{};
    foo.do_foo(||{ }).await;
}

fn main() {
    let _fut = x();
}

It seems like the combination of the member function together with the closure parameter might be the culprit. A top level async fn or a a "static" member function (without &self) doesn't cause an ICE.

This also crashes if x is not an async function and thereby no await is included at all:

fn x() {
    let foo = Foo{};
    foo.do_foo(||{ });
}
changed the title [-]Codegen ICE/regression with todays nightly when using async fn<T: Fn()>(&self, T)[/-] [+]Codegen ICE/regression with 2019-06-12 nightly when using async fn<T: Fn()>(&self, T)[/+] on Jun 14, 2019
Centril

Centril commented on Jun 14, 2019

@Centril
Contributor

Reduction of async fn version:

#![feature(async_await)]
#![allow(unused)]

async fn foo<F>(_: &(), _: F) {}

fn main() {
    async {
        foo(&(), || {}).await;
    };
}

Reduction of non-async fn version:

#![feature(async_await)]
#![allow(unused)]

async fn foo<F>(_: &(), _: F) {}

fn main() {
    foo(&(), || {});
}
eddyb

eddyb commented on Jun 20, 2019

@eddyb
Member

@Centril Note that you only need debuginfo-level = 1 to get the backtrace (2 is much more expensive). Maybe we even have builds with that enabled nowadays? Not sure though.
EDIT: also, someone needs to do this on linux, the backtraces are probably broken on macOS.

pnkfelix

pnkfelix commented on Jun 20, 2019

@pnkfelix
Member

triage: leaving unprioritized; assigning to @nikomatsakis with intent that they attach priority label as well as any Async-Await specific labels. Leaving nomination tag but hoping I'll remember to skip over it at this week's meeting.

5 remaining items

tmandry

tmandry commented on Jun 21, 2019

@tmandry
Member

Opened #62011.

added a commit that references this issue on Jun 21, 2019
dafc7ee
added a commit that references this issue on Jun 26, 2019

Auto merge of #62072 - eddyb:generator-memory-index, r=tmandry

bdd4bda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitAsyncAwait-PolishAsync-await issues that are part of the "polish" areaC-bugCategory: This is a bug.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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @eddyb@udoprog@nikomatsakis@pnkfelix@Centril

    Issue actions

      Codegen ICE/regression with 2019-06-12 nightly when using async fn<T: Fn()>(&self, T) · Issue #61793 · rust-lang/rust