Skip to content

std.fs.Walker segfault #7560

Description

@Cobertos

Platform: Window 10.0.19041 x64
Zig Version: 0.7.1+8fc765387

EDIT: Updated to latest version of zig

Trying to use std.fs.Walker. I'm getting a segmentation fault when traversing

conststd=@import("std");
pubfnmain () !void {
constalloc=std.heap.page_allocator;
varw=trystd.fs.walkPath(alloc, "");
while (tryw.next()) |entry| {
std.debug.print("Trying {}\n", .{ entry.path });
}
}

...will crash with...

cobertos@COBERTOS-DELL-L C:\Users\cobertos\Downloads\renamer
$ "..\zig-windows-x86_64-0.7.1+8fc765387\zig.exe" run rename.zig
Trying \.git
Trying \.git\config
Trying \.git\description
Trying \.git\HEAD
Trying \.git\hooks
Trying \.git\hooks\applypatch-msg.sample
Trying \.git\hooks\commit-msg.sample
Trying \.git\hooks\fsmonitor-watchman.sample
Trying \.git\hooks\post-update.sample
Trying \.git\hooks\pre-applypatch.sample
Trying \.git\hooks\pre-commit.sample
Trying \.git\hooks\pre-merge-commit.sample
Trying \.git\hooks\pre-push.sample
Trying \.git\hooks\pre-rebase.sample
Trying \.git\hooks\pre-receive.sample
Trying \.git\hooks\prepare-commit-msg.sample
Trying \.git\hooks\update.sample
Trying \.git\index
Trying \.git\info
Trying \.git\info\exclude
Trying \.git\modules
Trying \.git\modules\vendor
Trying \.git\modules\vendor\libpcre.zig
Trying \.git\modules\vendor\libpcre.zig\config
Trying \.git\modules\vendor\libpcre.zig\description
Trying \.git\modules\vendor\libpcre.zig\HEAD
Trying \.git\modules\vendor\libpcre.zig\hooks
Trying \.git\modules\vendor\libpcre.zig\hooks\applypatch-msg.sample
Trying \.git\modules\vendor\libpcre.zig\hooks\commit-msg.sample
Trying \.git\modules\vendor\libpcre.zig\hooks\fsmonitor-watchman.sample
Trying \.git\modules\vendor\libpcre.zig\hooks\post-update.sample
Trying \.git\modules\vendor\libpcre.zig\hooks\pre-applypatch.sample
Trying \.git\modules\vendor\libpcre.zig\hooks\pre-commit.sample
Trying \.git\modules\vendor\libpcre.zig\hooks\pre-merge-commit.sample
Trying \.git\modules\vendor\libpcre.zig\hooks\pre-push.sample
Trying \.git\modules\vendor\libpcre.zig\hooks\pre-rebase.sample
Trying \.git\modules\vendor\libpcre.zig\hooks\pre-receive.sample
Trying \.git\modules\vendor\libpcre.zig\hooks\prepare-commit-msg.sample
Trying \.git\modules\vendor\libpcre.zig\hooks\update.sample
Trying \.git\modules\vendor\libpcre.zig\index
Trying \.git\modules\vendor\libpcre.zig\info
Trying \.git\modules\vendor\libpcre.zig\info\exclude
Trying \.git\modules\vendor\libpcre.zig\logs
Trying \.git\modules\vendor\libpcre.zig\logs\HEAD
Trying \.git\modules\vendor\libpcre.zig\logs\refs
Trying \.git\modules\vendor\libpcre.zig\logs\refs\heads
Trying \.git\modules\vendor\libpcre.zig\logs\refs\heads\main
Trying \.git\modules\vendor\libpcre.zig\logs\refs\remotes
Segmentation fault at address 0x2c7d992e818
C:\Users\cobertos\Downloads\zig-windows-x86_64-0.7.1+8fc765387\lib\zig\std\fs.zig:2206:38: 0x7ff69f95af25 in std.fs.Walker::std.fs.Walker.next (rename.obj)
.dir = top.dir_it.dir,
^
???:?:?: 0xe5119ff89f in??? (???)
???:?:?: 0x8 in??? (???)

It always crashes on the same directory. If I have it traverse starting at .git or .git\modules\vendor\libpcre.zig\logs\refs instead of ., it will work no problem.
I also tried this on my entire C:\Users\cobertos\Downloads folder and got a segmentation fault on the same line of fs.zig, but on a different folder.

Tried debugging a bit, and adding std.debug.print("TEST {} {}\n", .{base.kind, base.name}); before line 2206 outputs

cobertos@COBERTOS-DELL-L C:\Users\cobertos\Downloads\renamer
$ "..\zig-windows-x86_64-0.7.1+8fc765387\zig.exe" run rename.zig
TEST Kind.Directory .git
Trying \.git
TEST Kind.File config
...
Trying \.git\modules\vendor\libpcre.zig\logs\refs
TEST Kind.Directory heads
Trying \.git\modules\vendor\libpcre.zig\logs\refs\heads
TEST Kind.File main
Trying \.git\modules\vendor\libpcre.zig\logs\refs\heads\main
TEST Kind.Directory remotes
Trying \.git\modules\vendor\libpcre.zig\logs\refs\remotes
TEST Kind.Directory Segmentation fault at address 0x28efedd0831

so it looks like the access to base.name?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions