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

Compiler panics when resuming async & printing frame info #9719

Open
KirilMihaylov opened this issue Sep 9, 2021 · 5 comments
Open

Compiler panics when resuming async & printing frame info #9719

KirilMihaylov opened this issue Sep 9, 2021 · 5 comments
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@KirilMihaylov
Copy link
Sponsor

Compiler version: 0.8.1
Platform: Windows

Minimal code code for reproduction:

const std = @import("std");

const print = std.debug.print;

pub fn main() void {
    var frame: @Frame(async_fn) = async async_fn();

    print("{any}", .{@typeInfo(@TypeOf(&frame))});

    resume &frame;

    print("{any}", .{@typeInfo(@TypeOf(&frame))});
}

fn async_fn() void {}

Output:

Assertion failed at /home/andy/dev/bootstrap-zig/zig/src/stage1/analyze.cpp:7236 in const_values_equal. This is a bug in the Zig compiler.thread 2812 panic: 
Unable to dump stack trace: debug info stripped
Zig Test...The following command exited with error code 3:
***\zig.exe build-exe ***\Zig Test\src\main.zig --cache-dir ***\Zig Test\zig-cache --global-cache-dir ***\AppData\Local\zig --name Zig Test --enable-cache
error: the following build command failed with exit code 3:
***\Zig Test\zig-cache\o\871ba5e971498e0b96c09685a51de112\build.exe ***\zig.exe ***\Zig Test ***\Zig Test\zig-cache ***\AppData\Local\zig run
@Vexu
Copy link
Member

Vexu commented Sep 9, 2021

On 0.9.0-dev.927+eb5e4ac49 on Linux I get a segfault on the resume but the printing works.

@wizzard0
Copy link

Reproduces on 0.9.0 master (d97928b) on OS X

@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Nov 20, 2021
@andrewrk andrewrk added this to the 0.10.0 milestone Nov 20, 2021
@stefan911
Copy link

resume without a suspend doesn't work. async and await are used together, this does async, resume without a suspend. So a request for a better compiler error message.

@KirilMihaylov
Copy link
Sponsor Author

@stefan911 While I agree with that statement, I can't help but emphasize on the compiler failing an assertion rather than printing an error message. I came across this randomly while tackling Zig's suspend/resume and async support.

@stefan911
Copy link

In some ways a compiler assertion is almost as good as an error message. It's the compiler crashes that really hurt. Have to agree with "tackling", the examples don't seem to lead towards best practices on async support.

@Vexu Vexu removed the stage1 The process of building from source via WebAssembly and the C backend. label Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

5 participants