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

Treat permission_denied as no_such_file when stat'ing unit files #8577

Conversation

z2oh
Copy link

@z2oh z2oh commented Apr 15, 2024

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.

Windows sometimes returns a permission_denied error when querying file attributes of a file that is marked for deletion by another process. When writing out index unit files, many processes are racing to rename temp files to a final output file which is often being queried by other processes, which causes this error to be returned with some frequency. Because this error code is unexpected, the compile will be failed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant