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

a big step towards std lib integration with async I/O #4404

Merged
merged 21 commits into from Feb 10, 2020
Merged

Conversation

andrewrk
Copy link
Member

@andrewrk andrewrk commented Feb 6, 2020

  • zig test gains --test-evented-io parameter and gains the ability
    to seamlessly run async tests.
  • std.ChildProcess opens its child process pipe with O_NONBLOCK when
    using evented I/O
  • std.io.getStdErr() gives a File that is blocking even in evented
    I/O mode.
  • Delete std.event.fs. The functionality is now merged into std.fs
    and async file system access (using a dedicated thread) is
    automatically handled.
  • std.fs.File can be configured to specify whether its handle is
    expected to block, and whether that is OK to block even when in
    async I/O mode. This makes async I/O work correctly for e.g. the
    file system as well as network.
  • std.fs.File has some deprecated functions removed.
  • Missing readv,writev,pread,pwrite,preadv,pwritev functions are added
    to std.os and std.fs.File. They are all integrated with async
    I/O.
  • std.fs.Watch is still bit rotted and needs to be audited in light
    of the new async/await syntax.
  • std.io.OutStream integrates with async I/O
  • linked list nodes in the std lib have default null values for
    prev and next.
  • Windows async I/O integration is enabled for reading/writing file
    handles.
  • Added std.os.mode_t. Integer sizes need to be audited.
  • Fixed compiler segfaults with async fn call with tuple after integer parameter #4403 which was causing compiler to crash.

This is all working towards:

./zig test ../test/stage1/behavior.zig --test-evented-io

Which does not successfully build yet. I'd like to enable behavioral
tests and std lib tests with --test-evented-io in the test matrix in the
future, to prevent regressions.

This adds `--test-evented-io` as a CLI parameter.

see #3117
 * `zig test` gainst `--test-evented-io` parameter and gains the ability
   to seamlessly run async tests.
 * `std.ChildProcess` opens its child process pipe with O_NONBLOCK when
   using evented I/O
 * `std.io.getStdErr()` gives a File that is blocking even in evented
   I/O mode.
 * Delete `std.event.fs`. The functionality is now merged into `std.fs`
   and async file system access (using a dedicated thread) is
   automatically handled.
 * `std.fs.File` can be configured to specify whether its handle is
   expected to block, and whether that is OK to block even when in
   async I/O mode. This makes async I/O work correctly for e.g. the
   file system as well as network.
 * `std.fs.File` has some deprecated functions removed.
 * Missing readv,writev,pread,pwrite,preadv,pwritev functions are added
   to `std.os` and `std.fs.File`. They are all integrated with async
   I/O.
 * `std.fs.Watch` is still bit rotted and needs to be audited in light
   of the new async/await syntax.
 * `std.io.OutStream` integrates with async I/O
 * linked list nodes in the std lib have default `null` values for
   `prev` and `next`.
 * Windows async I/O integration is enabled for reading/writing file
   handles.
 * Added `std.os.mode_t`. Integer sizes need to be audited.
 * Fixed #4403 which was causing compiler to crash.

This is working towards:

./zig test ../test/stage1/behavior.zig --test-evented-io

Which does not successfully build yet. I'd like to enable behavioral
tests and std lib tests with --test-evented-io in the test matrix in the
future, to prevent regressions.
 1. behavior tests with --test-evented-io
 2. std lib tests with --test-evented-io
 3. fuzz test evented I/O a bit, make it robust
 4. make sure it works on all platforms (kqueue, Windows IOCP,
    epoll/other)
 5. restart efforts on self-hosted
and fix "no-op casts" from incorrectly spilling
I used the wrong function here
by adding a maximum depth
@andrewrk
Copy link
Member Author

andrewrk commented Feb 8, 2020

I'm working on this case; will feel good about merging this after this works:

const std = @import("std");
const assert = std.debug.assert;

var global_frame: anyframe = undefined;

export fn entry() void {
    _ = async foo();
    resume global_frame;
}

const Foo = struct { x: i32 };

fn foo() anyerror!Foo {
    defer baz();
    return bar() catch |err| return err;
}

fn bar() anyerror!Foo {
    global_frame = @frame();
    suspend;
    return Foo{ .x = 99 };
}

fn baz() void {
    global_frame = @frame();
    suspend;
}

pub fn panic(msg: []const u8, stack_trace: ?*const std.builtin.StackTrace) noreturn {
    @breakpoint();
    unreachable;
}

Thanks to Vexu for the test cases.

Closes #3422
Closes #3646
Closes #3224
Closes #3327
Closes #3269
See #3180 for a more comprehensive plan to catch this problem. More
sophisticated control flow analysis is needed to provide compile errors
for returning local variable addresses from a function.
@andrewrk andrewrk added the breaking Implementing this issue could cause existing code to no longer compile or have different behavior. label Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Implementing this issue could cause existing code to no longer compile or have different behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compiler segfaults with async fn call with tuple after integer parameter
1 participant