Zig Version
0.17.0-dev.1282+c0f9b51d8
Steps to Reproduce, Observed Behavior, and Expected Behavior
This program crashes on aarch64-macos with 0.16.0 and 0.17.0-dev.1282+c0f9b51d8:
const std = @import("std");
pub fn main(init: std.process.Init) !void {
const io = init.io;
const cwd = std.Io.Dir.cwd();
std.debug.print("{}\n", .{try cwd.stat(io)});
}
Full error:
thread 12789901 panic: programmer bug caused syscall error: BADF
/Users/christophe/.local/soft/zig/zig-aarch64-macos-0.17.0-dev.1282+c0f9b51d8/lib/std/Io/Threaded.zig:14213:34: 0x104dc99cf in errnoBug (pouet)
if (is_debug) std.debug.panic("programmer bug caused syscall error: {t}", .{err});
^
/Users/christophe/.local/soft/zig/zig-aarch64-macos-0.17.0-dev.1282+c0f9b51d8/lib/std/Io/Threaded.zig:3897:51: 0x104df2d33 in fileStatPosix (pouet)
.BADF => |err| return errnoBug(err), // File descriptor used after closed.
^
/Users/christophe/.local/soft/zig/zig-aarch64-macos-0.17.0-dev.1282+c0f9b51d8/lib/std/Io/Threaded.zig:3618:20: 0x104e013f3 in dirStat (pouet)
return fileStat(t, .{
^
/Users/christophe/.local/soft/zig/zig-aarch64-macos-0.17.0-dev.1282+c0f9b51d8/lib/std/Io/Dir.zig:881:29: 0x104e32c33 in stat (pouet)
return io.vtable.dirStat(io.userdata, dir);
^
/Users/christophe/src/codeberg/chocapix/zig-chooser/pouet.zig:8:43: 0x104e277fb in main (pouet)
std.debug.print("{}\n", .{try cwd.stat(io)});
^
/Users/christophe/.local/soft/zig/zig-aarch64-macos-0.17.0-dev.1282+c0f9b51d8/lib/std/start.zig:790:30: 0x104e27d4f in callMain (pouet)
return wrapMain(root.main(.{
^
???:?:?: 0x18b7f7dff in start (/usr/lib/dyld)
zsh: abort ~/.local/soft/zig/zig-aarch64-macos-0.17.0-dev.1282+c0f9b51d8/zig run
Expected behavior: no crash.
No problem on x86_64-linux and interestingly, cwd().openDir(".").stat(io) works fine.
### Zig Version
0.17.0-dev.1282+c0f9b51d8
### Steps to Reproduce, Observed Behavior, and Expected Behavior
This program crashes on aarch64-macos with 0.16.0 and 0.17.0-dev.1282+c0f9b51d8:
```
const std = @import("std");
pub fn main(init: std.process.Init) !void {
const io = init.io;
const cwd = std.Io.Dir.cwd();
std.debug.print("{}\n", .{try cwd.stat(io)});
}
```
Full error:
```
thread 12789901 panic: programmer bug caused syscall error: BADF
/Users/christophe/.local/soft/zig/zig-aarch64-macos-0.17.0-dev.1282+c0f9b51d8/lib/std/Io/Threaded.zig:14213:34: 0x104dc99cf in errnoBug (pouet)
if (is_debug) std.debug.panic("programmer bug caused syscall error: {t}", .{err});
^
/Users/christophe/.local/soft/zig/zig-aarch64-macos-0.17.0-dev.1282+c0f9b51d8/lib/std/Io/Threaded.zig:3897:51: 0x104df2d33 in fileStatPosix (pouet)
.BADF => |err| return errnoBug(err), // File descriptor used after closed.
^
/Users/christophe/.local/soft/zig/zig-aarch64-macos-0.17.0-dev.1282+c0f9b51d8/lib/std/Io/Threaded.zig:3618:20: 0x104e013f3 in dirStat (pouet)
return fileStat(t, .{
^
/Users/christophe/.local/soft/zig/zig-aarch64-macos-0.17.0-dev.1282+c0f9b51d8/lib/std/Io/Dir.zig:881:29: 0x104e32c33 in stat (pouet)
return io.vtable.dirStat(io.userdata, dir);
^
/Users/christophe/src/codeberg/chocapix/zig-chooser/pouet.zig:8:43: 0x104e277fb in main (pouet)
std.debug.print("{}\n", .{try cwd.stat(io)});
^
/Users/christophe/.local/soft/zig/zig-aarch64-macos-0.17.0-dev.1282+c0f9b51d8/lib/std/start.zig:790:30: 0x104e27d4f in callMain (pouet)
return wrapMain(root.main(.{
^
???:?:?: 0x18b7f7dff in start (/usr/lib/dyld)
zsh: abort ~/.local/soft/zig/zig-aarch64-macos-0.17.0-dev.1282+c0f9b51d8/zig run
```
Expected behavior: no crash.
No problem on x86_64-linux and interestingly, `cwd().openDir(".").stat(io)` works fine.