You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
openjdk\bin keeps being emptied on VM testing-windows #252
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.
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.
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.
When you RDP into Windows, you get a different TMP/TEMP than usual and Windows (or the RDP client?) cleans these directories (seemingly upon restart, but maybe also sooner)
Bazel puts the output_base to the TMP directory by default (!!!)
The execroot is under the output_base and contains junctions pointing to... all your external repos. And your workspace. And to your JDK.
I'm pretty sure Windows is responsible for this. Whether this deletion occurs is controlled by the "HKLM:\System\CurrentControlSet\Control\Terminal Server\DeleteTempDirsOnExit" registry entry (it is 1 by default, and this problem goes away if you set it to 0).
This occurs at session end, which is sign out, not restart. It's much faster to reproduce by just signing out (from Powershell you can just do logoff to make this happen).
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 FILE_ATTRIBUTE_REPARSE_POINT bit (see GetFileAttributes()), they'll blindly follow the junction.
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.
bazelbuild/bazel#5038 is closed and released in 0.13.0 so this bug should no longer occur.
The implications:
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.
Activity
philwo commentedon Mar 21, 2018
@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.
katre commentedon Mar 21, 2018
No, I didn't run "bazel clean", although I might have tried to delete my entire bazel checkout in a fit of cleanliness.
philwo commentedon Mar 21, 2018
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.
katre commentedon Mar 21, 2018
I used "rmdir /s /q". Let me guess, that followed the junction and clobbered openjdk? Lovely.
katre commentedon Mar 21, 2018
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.
laszlocsomor commentedon Mar 22, 2018
@philwo : do you know if anything runs
git cleanon CI ? I heard that it can delete the JDK, though I haven't tried it myself yet.laszlocsomor commentedon Mar 22, 2018
@katre : IIRC
rmdir /s /qdoesn't follow junctions so that can't be the culprit. (I have to verify this when I get to the office today.)philwo commentedon Mar 22, 2018
@laszlocsomor CI does run „git clean“, but the testing-* machines are not used by CI.
philwo commentedon Mar 22, 2018
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.
philwo commentedon Mar 22, 2018
After I switched to PowerShell‘s „Remove-Item“ function, this worked fine.
laszlocsomor commentedon Mar 22, 2018
I tried it just now: neitherdel /s /qnorrd /s /qfollow junctions.laszlocsomor commentedon Mar 22, 2018
Ha!
del /s /q bazel-binwill follow the junction. Ouch.rd /s /q bazel-binwon't though.7 remaining items
katre commentedon Mar 27, 2018
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.
laszlocsomor commentedon Apr 17, 2018
@jasharpe found the culprit:
laszlocsomor commentedon Apr 17, 2018
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.
jasharpe commentedon Apr 17, 2018
To add slightly more color:
I'm pretty sure Windows is responsible for this. Whether this deletion occurs is controlled by the "HKLM:\System\CurrentControlSet\Control\Terminal Server\DeleteTempDirsOnExit" registry entry (it is 1 by default, and this problem goes away if you set it to 0).
This occurs at session end, which is sign out, not restart. It's much faster to reproduce by just signing out (from Powershell you can just do
logoffto make this happen).laszlocsomor commentedon Apr 17, 2018
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
FILE_ATTRIBUTE_REPARSE_POINTbit (see GetFileAttributes()), they'll blindly follow the junction.laszlocsomor commentedon Apr 17, 2018
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.
laszlocsomor commentedon Apr 17, 2018
@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:
laszlocsomor commentedon May 16, 2018
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.