`<filesystem>`: `exists()` fails with "Access denied" for certain type of symlinks
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
Describe the bug
We use std::filesystem::exists to check existence of paths on the system. Since few days we started to see an error where this function would fail with Access Denied. Unfortunately I could not get a fully reproducible example but I am gonna describe what I noticed.
This is the logged error
Exists D:\some_path\WebKit.framework = 0 with ec 5 and msg Access is denied.
This is the list of paths inside some_path
d----- 11/15/2024 4:51 AM _SceneKit_SwiftUI.framework
d----- 11/15/2024 4:51 AM _StoreKit_SwiftUI.framework
d----- 11/15/2024 4:51 AM _SwiftData_SwiftUI.framework
d----- 11/15/2024 4:51 AM _Translation_SwiftUI.framework
-a---l 11/15/2024 4:51 AM 0 AuthenticationServices.framework
-a---l 11/15/2024 4:51 AM 0 JavaScriptCore.framework
-a---l 11/15/2024 4:51 AM 0 SafariServices.framework
-a---l 11/15/2024 4:51 AM 0 WebKit.framework
The function fails on all the paths having the a and l bit on while it succeeds on the others.
Permissions should not be the problem: I tried with different users and with all of them I can read the files using powershell (with a simple ls).
Other things worth mentioning: these are symlinks that point to other symlinks
$ stat Modules
File: Modules -> Versions/Current/Modules
Size: 24 Blocks: 0 IO Block: 65536 symbolic link
$ stat Versions/Current/Modules
File: Versions/Current/Modules
Size: 0 Blocks: 0 IO Block: 65536 directory
$ stat Versions/Current
File: Versions/Current -> A
Size: 1 Blocks: 0 IO Block: 65536 symbolic link
$ stat Versions/A/
File: Versions/A/
Size: 0 Blocks: 0 IO Block: 65536 directory
again, I tried to repro by re-building a folder structure of this type but I couldn't reproduce the error
Any advice?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at std::filesystem::exists and investigate the Windows handling of the described framework-style symlinks, especially links that point through another symlink. First try to reproduce the Access Denied error with the shown chain and compare it with PowerShell access. Done means the failure is understood and corrected, with the behavior covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100