Skip to content

zig-cache gets into non-recoverable state during "zig build" #10865

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

Closed
marler8997 opened this issue Feb 11, 2022 · 7 comments
Closed

zig-cache gets into non-recoverable state during "zig build" #10865

marler8997 opened this issue Feb 11, 2022 · 7 comments
Labels
bug Observed behavior contradicts documented or intended behavior os-windows zig build system std.Build, the build runner, `zig build` subcommand, package management

Comments

@marler8997
Copy link
Contributor

marler8997 commented Feb 11, 2022

Zig Version

0.10.0-dev.620+9981b3fd2

Steps to Reproduce

It's unclear how the zig-cache got into this state. Possibly by running "zig build" may times with changes to the project or cleaning the local-cache between runs on an old slow machine.

Expected Behavior

zig build not to get an error trying to run the build runner executable.

Actual Behavior

zig failed to execute the build runner executable because it doesn't exist, but it thinks it does because it has an entry in the cache along with a "build.pdb" and "build.obj" file (this is on Windows) but there is no "build.exe" file like there should be.

Insight

I'm not sure if the build runner works differently, but I would have expected Zig to build the build runner into a tmp directory first, then at the last step rename that directory into zig-cache\o. This way if Zig fails/crashes while trying to populate that directory, then we won't get into an invalid state like this. If Zig is already doing this for the build runner then we'll have to investigate how this happened further.

@marler8997 marler8997 added the bug Observed behavior contradicts documented or intended behavior label Feb 11, 2022
@joukoltmk
Copy link

I ran into a similar (same?) issue while experimenting with hot reloading. It seems to be a zig build-cache problem specifically on windows (I am only on a windows machine so I can't comment on the behavior in other OS)

Zig version

zig-windows-x86_64-0.10.0-dev.290+3901b6fb0

Expected Behavior

Run "zig build run" without issues

Actual Behavior

If executable/library with exactly the same contents/hash is created then command fails with "error: AccessDenied".

Steps to Reproduce

Run "zig init-exe". Run "zig build run". Then modify the code in some way and build. Then reverse modifications and build it in its original state. You will now get the error.

Steps to fix?

From the process monitor one can observe that the build failed with SetRenameInformationFile with ReplaceIfExists set to true. From the documentation:

Even if ReplaceIfExists is set to TRUE, the rename operation will still fail if a file with the same name already exists and is a directory, a read-only file, or a currently executing file

So the issue here is most likely that if you create a build artifact with the same hash/content then on windows cache directory renaming fails.

@marler8997
Copy link
Contributor Author

@joukoltmk you ran into this issue: #8362

Very similar to this one but I think might have a different root cause.

@joukoltmk
Copy link

Ah yes, thanks. That issue seems to have the same problem I have.

@andrewrk andrewrk added os-windows zig build system std.Build, the build runner, `zig build` subcommand, package management labels Aug 19, 2022
@andrewrk andrewrk added this to the 0.11.0 milestone Aug 19, 2022
@andrewrk
Copy link
Member

Please try to add more clues to this issue if you find them - as is I'm not sure I would be able to work on this bug without anything more to go on.

@nektro
Copy link
Contributor

nektro commented Aug 19, 2022

marler's issue could be related to #6452, but no log was posted so unsure

@nektro
Copy link
Contributor

nektro commented Aug 19, 2022

but I would have expected Zig to build the build runner into a tmp directory first, then at the last step rename that directory into zig-cache\o

not possible due to #6364 still being open

@marler8997
Copy link
Contributor Author

I have been doing close to zero development on Windows in the last few months so I haven't seen this. Since it's unclear how to reproduce this right now and I haven't been able to see this I can't provide any more details. Given this, there's nothing actionable until someone else sees this again and is able to provide more details or a way to reproduce so I'll close it until we get more information.

@andrewrk andrewrk removed this from the 0.11.0 milestone Aug 23, 2022
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 os-windows zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

No branches or pull requests

4 participants