-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavioros-windowsMicrosoft WindowsMicrosoft Windowsstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
I triggered an assertion failure when iterating a long file name with std.fs.walkPath:
D:\application\zig-windows-x86_64-0.8.0-dev.1431+c760532be\lib\zig\std\debug.zig:223:14: 0x7ff667831078 in std.debug.assert (walk.obj)
if (!ok) unreachable; // assertion failure
^
D:\application\zig-windows-x86_64-0.8.0-dev.1431+c760532be\lib\zig\std\unicode.zig:43:11: 0x7ff66785762e in std.unicode.utf8Encode (walk.obj)
assert(out.len >= length);
^
D:\application\zig-windows-x86_64-0.8.0-dev.1431+c760532be\lib\zig\std\unicode.zig:604:36: 0x7ff66784f9d5 in std.unicode.utf16leToUtf8 (walk.obj)
end_index += try utf8Encode(codepoint, utf8[end_index..]);
^
D:\application\zig-windows-x86_64-0.8.0-dev.1431+c760532be\lib\zig\std\fs.zig:615:68: 0x7ff66784f4c5 in std.fs.Iterator::std.fs.Iterator.next (walk.obj)
const name_utf8_len = std.unicode.utf16leToUtf8(self.name_data[0..], name_utf16le) catch unreachable;
^
D:\application\zig-windows-x86_64-0.8.0-dev.1431+c760532be\lib\zig\std\fs.zig:2266:36: 0x7ff66784c0f9 in std.fs.Walker::std.fs.Walker.next (walk.obj)
if (try top.dir_it.next()) |base| {
^
It seems that std.fs.Dir.Iterator on Windows wrongly assumes that the filename converted into UTF-8 will fit in 256 bytes.
Line 564 in 6787f16
| name_data: [256]u8, |
Changing it to 512 fixed my particular use case.
I don't know much about this, perhaps assuming 256 Unicode code points would be a safer bet?
squeek502
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavioros-windowsMicrosoft WindowsMicrosoft Windowsstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.