Treat permission_denied
as no_such_file
when stat'ing unit files
#8577
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the same root problem as in #8224
I tried to fix this inside platform-specific code (like how I was able to fix the #8224 with llvm@8c97bd8) but there are fewer constraints to work with for the general call to the
status
function.In the end, leaking this Windows detail through the
llvm::sys::fs
abstraction seemed to be the least egregious option.I left a comment in the source explaining things:
On Windows, if a file is queried for attributes after another process marks that file for deletion but is still holding the file handle, the query will fail with a misleading "permission denied" error. This race happens frequently during index generation as many clang processes are racing to rename temporary index units to the same destination (incurring a delete on the destination file, which is queried in the status call just above). Seeing this error code here most likely means that the destination file is just marked for deletion, so treat it the same as a "no such file" error. A real permission error is unlikely, as the write to this file by another clang process would have already failed with "permission denied." Even if this error code is legitimate, the ensuing write will fail for the same reason.