Skip to content

[cherrypick swift/release/6.0] Return errc::no_such_file_or_directory in fs::access if GetFileAttributesW fails #8518

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

Merged
merged 1 commit into from
Apr 4, 2024
Merged

[cherrypick swift/release/6.0] Return errc::no_such_file_or_directory in fs::access if GetFileAttributesW fails #8518

merged 1 commit into from
Apr 4, 2024

Conversation

z2oh
Copy link

@z2oh z2oh commented Apr 2, 2024

Cherry picking this fix for #8224 into the swift/release/6.0 branch

(cherry picked from commit 9961c03)

…ttributesW` fails (llvm#83495)

Fixes llvm#83046

There is a race condition when calling `GetFileAttributesW` that can
cause it to return `ERROR_ACCESS_DENIED` on a path which exists, which
is unexpected for callers using this function to check for file
existence by passing `AccessMode::Exist`. This was manifesting as a
compiler crash on Windows downstream in the Swift compiler when using
the `-index-store-path` flag (more information in
#8224).

I looked for alternate APIs to avoid bringing in `shlwapi.h`, but didn't
see any good candidates. I'm not tied at all to this solution, any
feedback and alternative approaches are more than welcome.

(cherry picked from commit 9961c03)
@compnerd
Copy link
Member

compnerd commented Apr 2, 2024

@swift-ci please test

@compnerd
Copy link
Member

compnerd commented Apr 2, 2024

@compnerd
Copy link
Member

compnerd commented Apr 2, 2024

Explanation: Work around a potential misreporting of file existence checks on Windows.
Scope: Fixes a windows specific issue in LLVM which has been applied upstream.
Issue: llvm#8224
Risk: Very low risk, it just special cases an error value in a Windows specific codepath.
Testing: This was tested through the LLVM CI, the Swift CI, and locally.
Reviewer: @compnerd

@DougGregor DougGregor merged commit 48a1f0f into swiftlang:swift/release/6.0 Apr 4, 2024
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