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

Build failed on Win10 after 0.12.0-dev.164 #17049

Closed
ndbn opened this issue Sep 2, 2023 · 5 comments · Fixed by #17053
Closed

Build failed on Win10 after 0.12.0-dev.164 #17049

ndbn opened this issue Sep 2, 2023 · 5 comments · Fixed by #17053
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@ndbn
Copy link
Contributor

ndbn commented Sep 2, 2023

Zig Version

0.12.0-dev.252+5dc2db805

Steps to Reproduce and Observed Behavior

Old windows 10 (1709).
Last working version I have - zig_0.12.0-dev.152+411462e1c
Oldest not working version I have - zig-windows-x86_64-0.12.0-dev.185+49075d205
Same not works with lastest(RN) version - zig-windows-x86_64-0.12.0-dev.252+5dc2db805

I look for possible reason in changes between versions 152 and 185 and found this 0.12.0-dev.164 6780a6b...7a834e2

Mine builtin.os.version_range.windows = target.Target.Os.WindowsVersion.Range{ .min = WindowsVersion.win10_rs3, .max = WindowsVersion.win10_rs3 }

$ mkdir test5

$ cd test5

$ zig init-exe
info: Created build.zig
info: Created src\main.zig
info: Next, try `zig build --help` or `zig build run`


$ zig build
error.Unexpected NTSTATUS=0xc00000bb
C:\!SOFT\zig\zig\lib\std\os.zig:2708:48: 0x7ff630f8738d in renameatW (build.exe.obj)
        else => return windows.unexpectedStatus(rc),
                                               ^
C:\!SOFT\zig\zig\lib\std\os.zig:2531:25: 0x7ff630f5c7f5 in renameat (build.exe.obj)
        return renameatW(old_dir_fd, old_path_w.span(), new_dir_fd, new_path_w.span(), windows.TRUE);
                        ^
C:\!SOFT\zig\zig\lib\std\fs.zig:232:24: 0x7ff630f5e23d in finish (build.exe.obj)
        try os.renameat(self.dir.fd, self.tmp_path_buf[0..], self.dir.fd, self.dest_basename);
                       ^
C:\!SOFT\zig\zig\lib\std\fs.zig:2589:31: 0x7ff630f5dece in updateFile (build.exe.obj)
        try atomic_file.finish();
                              ^
C:\!SOFT\zig\zig\lib\std\Build\Step\InstallArtifact.zig:133:36: 0x7ff630f2796e in make (build.exe.obj)
        const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_dest_path, .{}) catch |err| {
                                   ^
C:\!SOFT\zig\zig\lib\std\Build\Step.zig:177:13: 0x7ff630ec2cd4 in make (build.exe.obj)
    s.makeFn(s, prog_node) catch |err| switch (err) {
            ^
C:\!SOFT\zig\zig\lib\build_runner.zig:833:31: 0x7ff630e82878 in workerMakeOneStep (build.exe.obj)
    const make_result = s.make(&sub_prog_node);
                              ^
C:\!SOFT\zig\zig\lib\std\Thread\Pool.zig:94:39: 0x7ff630e5e79e in runFn (build.exe.obj)
            @call(.auto, func, closure.arguments);
                                      ^
C:\!SOFT\zig\zig\lib\std\Thread\Pool.zig:133:18: 0x7ff630ee1ec8 in worker (build.exe.obj)
            runFn(&run_node.data);
                 ^
C:\!SOFT\zig\zig\lib\std\Thread.zig:412:13: 0x7ff630ec25fc in callFn__anon_13439 (build.exe.obj)
            @call(.auto, f, args);
            ^
C:\!SOFT\zig\zig\lib\std\Thread.zig:524:30: 0x7ff630e82044 in entryFn (build.exe.obj)
                return callFn(f, self.fn_args);
                             ^
???:?:?: 0x7ffdafd81fe3 in ??? (KERNEL32.DLL)
???:?:?: 0x7ffdb1d5efc0 in ??? (ntdll.dll)
error.Unexpected NTSTATUS=0xc00000bb
C:\!SOFT\zig\zig\lib\std\os\windows.zig:1041:40: 0x7ff630f0b547 in DeleteFile (build.exe.obj)
        else => return unexpectedStatus(rc),
                                       ^
C:\!SOFT\zig\zig\lib\std\os.zig:2434:30: 0x7ff630eedd53 in unlinkatW (build.exe.obj)
    return windows.DeleteFile(sub_path_w, .{ .dir = dirfd, .remove_dir = remove_dir });
                             ^
C:\!SOFT\zig\zig\lib\std\fs.zig:1858:21: 0x7ff630ed4e63 in deleteFileW (build.exe.obj)
        os.unlinkatW(self.fd, sub_path_w, 0) catch |err| switch (err) {
                    ^
C:\!SOFT\zig\zig\lib\std\fs.zig:1825:36: 0x7ff630eb6df8 in deleteFile (build.exe.obj)
            return self.deleteFileW(sub_path_w.span());
                                   ^
C:\!SOFT\zig\zig\lib\std\fs.zig:215:32: 0x7ff630f5e036 in deinit (build.exe.obj)
            self.dir.deleteFile(&self.tmp_path_buf) catch {};
                               ^
C:\!SOFT\zig\zig\lib\std\fs.zig:2585:33: 0x7ff630f5dee4 in updateFile (build.exe.obj)
        defer atomic_file.deinit();
                                ^
C:\!SOFT\zig\zig\lib\std\Build\Step\InstallArtifact.zig:133:36: 0x7ff630f2796e in make (build.exe.obj)
        const p = fs.Dir.updateFile(cwd, full_src_path, cwd, full_dest_path, .{}) catch |err| {
                                   ^
C:\!SOFT\zig\zig\lib\std\Build\Step.zig:177:13: 0x7ff630ec2cd4 in make (build.exe.obj)
    s.makeFn(s, prog_node) catch |err| switch (err) {
            ^
C:\!SOFT\zig\zig\lib\build_runner.zig:833:31: 0x7ff630e82878 in workerMakeOneStep (build.exe.obj)
    const make_result = s.make(&sub_prog_node);
                              ^
C:\!SOFT\zig\zig\lib\std\Thread\Pool.zig:94:39: 0x7ff630e5e79e in runFn (build.exe.obj)
            @call(.auto, func, closure.arguments);
                                      ^
C:\!SOFT\zig\zig\lib\std\Thread\Pool.zig:133:18: 0x7ff630ee1ec8 in worker (build.exe.obj)
            runFn(&run_node.data);
                 ^
C:\!SOFT\zig\zig\lib\std\Thread.zig:412:13: 0x7ff630ec25fc in callFn__anon_13439 (build.exe.obj)
            @call(.auto, f, args);
            ^
C:\!SOFT\zig\zig\lib\std\Thread.zig:524:30: 0x7ff630e82044 in entryFn (build.exe.obj)
                return callFn(f, self.fn_args);
                             ^
???:?:?: 0x7ffdafd81fe3 in ??? (KERNEL32.DLL)
???:?:?: 0x7ffdb1d5efc0 in ??? (ntdll.dll)
install test5: error: unable to update file from 'C:\WORK\Projects\Zig\test5\zig-cache\o\7e780527027a5f40838a478f0a9aa39f\test5.exe' to 'C:\WORK\Projects\Zig\test5\zig-out\bin\test5.exe': Unexpected
Build Summary: 1/3 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
+- install test5 failure
error: the following build command failed with exit code 1:
C:\WORK\Projects\Zig\test5\zig-cache\o\163f4e446561a9790e3ef2ae18a7a665\build.exe C:\!SOFT\zig\zig\zig.exe C:\WORK\Projects\Zig\test5 C:\WORK\Projects\Zig\test5\zig-cache C:\Users\twit\AppData\Local\zig

Expected Behavior

Sucessful build

@ndbn ndbn added the bug Observed behavior contradicts documented or intended behavior label Sep 2, 2023
@squeek502
Copy link
Collaborator

squeek502 commented Sep 2, 2023

NTSTATUS 0xc00000bb is STATUS_NOT_SUPPORTED.

Looks like while FILE_RENAME_POSIX_SEMANTICS was added in Win10 RS1, FILE_RENAME_IGNORE_READONLY_ATTRIBUTE (which we also set) wasn't added until Win10 RS5.

We have a few options here:

  1. Catch STATUS_NOT_SUPPORTED and use the fallback (non-POSIX_SEMANTICS rename) in that case
  2. Add a check for win10_rs5 and only add FILE_RENAME_IGNORE_READONLY_ATTRIBUTE if the version is >= .win10_rs5 (this would lead to three distinct differences in functionality: >= win10_rs5, >= win10_rs1 and < win10_rs5, and < win10_rs1).
  3. Bump the isAtLeast(.win10_rs1) check up to isAtLeast(.win10_rs5) and keep STATUS_NOT_SUPPORTED as unexpected/unreachable (effectively only using FILE_RENAME_POSIX_SEMANTICS when we know we can also use FILE_RENAME_IGNORE_READONLY_ATTRIBUTE).

Personally I'm leaning towards option 3.

cc @matu3ba

@ndbn
Copy link
Contributor Author

ndbn commented Sep 2, 2023

I also found information in this link, about return values, it also can be one of
STATUS_NOT_IMPLEMENTED,
STATUS_NOT_SUPPORTED,
STATUS_INVALID_INFO_CLASS
for older Windows versions. May be they need to be checked for brunching to need_fallback.

@matu3ba
Copy link
Contributor

matu3ba commented Sep 2, 2023

Personally I'm leaning towards option 3.

My reasoning would be to keep the behavior and code as simple as possible, so also option 3 unless one comes up with a strong justification why updating to .win10_rs5 would be not possible.

matu3ba added a commit to matu3ba/zig that referenced this issue Sep 2, 2023
FILE_RENAME_IGNORE_READONLY_ATTRIBUTE requires win10_rs5 and
posix semantics for renameatW are available with win10_rs1.
Keep it as simple as possible, since it is reasonable to expect users being
able to update win10_rs5 or use non-posix semantics instead.

Closes ziglang#17049.
@ndbn
Copy link
Contributor Author

ndbn commented Sep 2, 2023

I suppose DeleteFile in windows.zig also need to be change

matu3ba added a commit to matu3ba/zig that referenced this issue Sep 2, 2023
…r posix semantics

Usage of FILE_RENAME_IGNORE_READONLY_ATTRIBUTE or
FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE for posix semantics require
win10_rs5 instead of win10_rs1 necessary for posix semantics. Keep it as simple
as possible, since it is reasonable to expect users being able to update
win10_rs5 or use non-posix semantics instead.

Closes ziglang#17049.
kubkon pushed a commit that referenced this issue Sep 3, 2023
…r posix semantics

Usage of FILE_RENAME_IGNORE_READONLY_ATTRIBUTE or
FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE for posix semantics require
win10_rs5 instead of win10_rs1 necessary for posix semantics. Keep it as simple
as possible, since it is reasonable to expect users being able to update
win10_rs5 or use non-posix semantics instead.

Closes #17049.
@ndbn
Copy link
Contributor Author

ndbn commented Sep 3, 2023

Thanks

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

Successfully merging a pull request may close this issue.

3 participants