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

Windows: Make runfiles symlink tree actions depend on the runfiles artifacts. #12018

Closed
wants to merge 1 commit into from

Conversation

benjaminp
Copy link
Collaborator

@benjaminp benjaminp commented Aug 28, 2020

Windows distinguishes between symlinks to files and symlinks to directories. The
code to create symlink trees on Windows thus inspects the targets of the links
to learn what kind of symlink to make. Unfortunately, the symlinking code did
not depend on the link targets actually being created. This race could lead to
non-deterministic and non-functional symlink trees.

Fix this problem by depending on runfiles artifacts in the SymtreeTreeAction
when the host platform is Windows.

It's certainly possible to avoid this os-dependent input dependency—by using
in-memory Artifact state for the in-process implementation and extending the
runfiles manifest format to indicate target type for build-runfiles-windows—but
this commit is the most straightforward change that remediates the serious
correctness issue represented by the previous state.

This topic has a long history. When Windows runfiles trees were actually copies
of artifacts, the "symlink" action obviously had to depend on the origin
artifacts (41f4456). That code was removed in
an interregnum period where runfiles trees weren't supported at all on Windows
(0885abd). However, the dependency was not
added back when Windows symlinked runfiles trees support was finally added
(b592dbd).

Fixes #12033.

@benjaminp benjaminp changed the title Make runfiles symlink tree actions depend on the runfiles artifacts. Windows: Make runfiles symlink tree actions depend on the runfiles artifacts. Aug 28, 2020
@meteorcloudy
Copy link
Member

@benjaminp Thanks for fixing this!

@meteorcloudy meteorcloudy self-requested a review September 1, 2020 07:44
@meteorcloudy meteorcloudy self-assigned this Sep 1, 2020
…tifacts.

Windows distinguishes between symlinks to files and symlinks to directories. The
code to create symlink trees on Windows thus inspects the targets of the links
to learn what kind of symlink to make. Unfortunately, the symlinking code did
not depend on the link targets actually being created. This race could lead to
non-deterministic and non-functional symlink trees.

Fix this problem by depending on runfiles artifacts in the SymtreeTreeAction
when the host platform is Windows.

It's certainly possible to avoid this os-dependent input dependency—by using
in-memory Artifact state for the in-process implementation and extending the
runfiles manifest format to indicate target type for build-runfiles-windows—but
this commit is the most straightforward change that remediates the serious
correctness issue represented by the previous state.

This topic has a long history. When Windows runfiles trees were actually copies
of artifacts, the "symlink" action obviously had to depend on the origin
artifacts (41f4456). That code was removed in
an interregnum period where runfiles trees weren't supported at all on Windows
(0885abd). However, the dependency was not
added back when Windows symlinked runfiles trees support was finally added
(b592dbd).

Fixes bazelbuild#12033.
@nikhilm
Copy link
Contributor

nikhilm commented Sep 2, 2020

Thanks @benjaminp !

Would appreciate if this could be picked for 3.5.1 (unless 3.5 is magically still a possibility).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Race condition with runfiles tree creation on Windows
4 participants