Skip to content

[cherrypick stable/20230725] Return errc::no_such_file_or_directory in fs::access if GetFileAttributesW fails (#83495) #8515

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 9, 2024
Merged

Conversation

z2oh
Copy link

@z2oh z2oh commented Apr 1, 2024

Cherry picking this fix for #8224 into the stable/20230725 branch

@compnerd
Copy link
Member

compnerd commented Apr 1, 2024

Could you please perform the cherry-pick with -x to record the original commit that is being cherry-picked?

…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

@swift-ci please test Windows platform

@compnerd compnerd merged commit cb197f7 into swiftlang:stable/20230725 Apr 9, 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.

2 participants