Skip to content

[🍒 stable/20230725] Handle new delete_pending error code when stating index unit files #8848

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

Conversation

z2oh
Copy link

@z2oh z2oh commented Jun 5, 2024

Explanation: Fixes a common compiler crash on Windows when generating the index while building.
Scope: This crash happens frequently when building large projects on Windows when indexing while building. The delete_pending error code is only generated on Windows when the status function is called against a path that has been marked for deletion.
Issue: This issue tracked the addition of the new error code, which was done in support of the fix here: llvm#89137
Risk: Very low risk, this change introduces handling for a new error code that can only be generated under specific conditions on Windows.
Testing: Tested through LLVM CI and locally.
Reviewer: @compnerd

Multiple clang processes race to write out the same index file via renaming a newly generated index file ontop of the stale one. On Windows, there is a small window where the destination path is marked for deletion, and querying the file at this time would return a misleading permission_denied error (which is the Win32 error mapping from the underlying NTSTATUS code STATUS_DELETE_PENDING). An upstream change has modified the fs::status function on Windows to detect this case and return a more accurate delete_pending error code, which can be handled here as if the file is already deleted (i.e. no_such_file_or_directory)

(cherry picked from commit dd2cc94)

Multiple clang processes race to write out the same index file via renaming a newly generated index file ontop of the stale one. On Windows, there is a small window where the destination path is marked for deletion, and querying the file at this time would return a misleading `permission_denied` error (which is the Win32 error mapping from the underlying NTSTATUS code `STATUS_DELETE_PENDING`). An upstream change has modified the `fs::status` function on Windows to detect this case and return a more accurate `delete_pending` error code, which can be handled here as if the file is already deleted (i.e. `no_such_file_or_directory`)

(cherry picked from commit dd2cc94)
@compnerd
Copy link
Member

compnerd commented Jun 5, 2024

CC: @bnbarham

@compnerd
Copy link
Member

compnerd commented Jun 5, 2024

@swift-ci please test

@bnbarham bnbarham self-requested a review June 5, 2024 17:34
@bnbarham
Copy link

bnbarham commented Jun 5, 2024

Seems like this might need another cherry-pick too?

llvm-project/clang/lib/Index/IndexUnitWriter.cpp:245:74: error: no member named 'delete_pending' in 'llvm::errc'
    if (EC != llvm::errc::no_such_file_or_directory && EC != llvm::errc::delete_pending) {

@z2oh
Copy link
Author

z2oh commented Jun 5, 2024

Thanks for the quick review! Yeah, I just noticed that CI failure. Cherry-pick for the other change is here: #8850

@compnerd
Copy link
Member

compnerd commented Jun 6, 2024

@swift-ci please test

@compnerd compnerd merged commit b2bf63b into swiftlang:stable/20230725 Jun 7, 2024
3 checks passed
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.

3 participants