-
Notifications
You must be signed in to change notification settings - Fork 135
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
openjdk\bin keeps being emptied on VM testing-windows #252
Comments
@katre Do you remember if you ran "bazel clean" or "bazel clean --expunge" at some point in time? @laszlocsomor I wonder if Bazel is following symlinks for the local JDK, ends up in C:\openjdk and thoroughly "cleans it up" ... any idea? FYI, we don't see this on the Buildkite VMs, because there the buildkite user does not have write-permissions to C:, so it can't delete the folder. |
No, I didn't run "bazel clean", although I might have tried to delete my entire bazel checkout in a fit of cleanliness. |
How did you delete the checkout? :D Some tools in Windows don't understand symbolic links and then follow them. I think this could cause the problem. |
I used "rmdir /s /q". Let me guess, that followed the junction and clobbered openjdk? Lovely. |
Given the number of tests that create bazel workspaces and then clean them up after, this would probably be triggered no matter what I had done. |
@philwo : do you know if anything runs |
@katre : IIRC |
@laszlocsomor CI does run „git clean“, but the testing-* machines are not used by CI. |
Thinking about it, IIRC I initially used „rmdir /s /q“ to clean up after a CI run in the infra scripts and that indeed followed Bazel‘s bazel-out junction and deleted the entire JDK. |
After I switched to PowerShell‘s „Remove-Item“ function, this worked fine. |
|
Ha! |
So, moment of truth (at least on my machine... who knows, maybe there's some registry setting that controls rd's behavior): I created two directories (
Deleting with
Deleting with
|
Huh, that's interesting. So the takeaway seems to be that I (and, I guess, Bazel) should use "del" on Windows, not "rmdir". This seems to be pointing back towards setting up a shell_tools toolchain, with items for "shell", "rmdir", and whatever other system-level utilities are needed, so we can properly switch them based on the platform in use. |
I don't believe Bazel does that. Not with Do you have a repro? I'd like to investigate. |
I mean, I don't believe Bazel uses either |
I might try today and see if I can reproduce this. My theory is as follows:
I think that the last step there is using whatever msys is providing, presumably some variant of "rm -r", and I don't know which of the "rmdir"/"del" modes that maps to. |
@katre , did you get to try this out? |
Haven't had a chance to. I'll see if I can today. |
Okay, I was unable to reproduce this by running tests. My assumption then is that I was doing something strange while testing manually and triggered the wrong delete command. Thanks for the help, I'll close the issue now. |
@jasharpe found the culprit:
|
Here's the culprit: https://github.com/bazelbuild/bazel/blob/9dd14499876a4ca8f51a890bccc84971d16c0332/src/main/cpp/blaze_util_windows.cc#L205 By checking all possible TMP envvars, we try very hard to do the wrong thing. |
To add slightly more color:
|
That means junctions are inherently dangerous: by default they look like directories, and if a directory-tree deleter routine is unaware of junctions and doesn't check the |
A better approach would be to do the same as on Linux: create directories with file symlinks in them. That way deleting the directory tree is safe because deleting a file symlink just deletes the symlink. The downside is of course that creating symlinks requires admin privileges. |
@philwo pointed out that directory symlinks would be risky on Linux too. And AFAIK we don't even create directory symlinks on any platform other than Windows. @dslomov : FYI. The implications:
|
bazelbuild/bazel#5038 is closed and released in 0.13.0 so this bug should no longer occur.
On second thought, we cannot fix the Remote Desktop server not to follow junctions while deleting the temp directory, and abstaining from using junctions would limit the usability of Bazel, particularly on older Windows versions that don't support unprivileged symlink creation. Therefore I think Bazel is working as intended. |
Earlier today, I noticed that on the testing-windows VM, the C:\openjdk\bin directory (and several others) was empty. @philwo then re-imaged the VM, and everything was fine.
Just now, I logged into the VM again, and c:\openjdk\bin is again empty, with no Java binaries to be found.
The text was updated successfully, but these errors were encountered: