Fix filesystem::weakly_canonical() on Win11 24H2#4844
Merged
StephanTLavavej merged 1 commit intomicrosoft:mainfrom Jul 21, 2024
Merged
Fix filesystem::weakly_canonical() on Win11 24H2#4844StephanTLavavej merged 1 commit intomicrosoft:mainfrom
filesystem::weakly_canonical() on Win11 24H2#4844StephanTLavavej merged 1 commit intomicrosoft:mainfrom
Conversation
Member
Author
|
Overriding policy as @zacklj89 approved the internal mirror MSVC-PR-566203. |
This was referenced Jul 26, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We have a regression test for DevCom-538510 (internal VSO-850856) "
std::filesystem::weakly_canonicalerroneously throws an exception":STL/tests/std/tests/P0218R1_filesystem/test.cpp
Lines 3233 to 3237 in ecbc1ef
This has regressed on the upcoming Win11 24H2, where we throw an exception (again). The relevant code is:
STL/stl/inc/filesystem
Lines 4127 to 4144 in ecbc1ef
After calling
_Canonical(), anything other than_Err == __std_win_error::_Successor__std_is_file_not_found(_Err)is considered a hard error (which will cause the non-error_codeoverload to throw afilesystem_error).In current OSes, the
fileWithSuffixscenario results in_Invalid_namehere. (Locally verified on Win11 23H2. Presumably we get the same behavior in the GitHub PR/CI system running Server 2022 21H2, although I didn't verify that.)In Win11 24H2, we get
_Directory_name_is_invalid, which isn't recognized by__std_is_file_not_found. 💥The fix is backwards-compatible and a simple one-liner: add this error code enumerator to the list of synonyms that
__std_is_file_not_foundrecognizes. The plain meaning of_Directory_name_is_invalidis clearly a subset of_Invalid_name.I've manually verified this (with significant but perhaps not surprising logistical difficulty) in an Azure VM with Win11 24H2. Regular test coverage will be provided by the MSVC-internal test harness (which is how we found this), and eventually by the GitHub test harness once Server 2025 24H2 is officially released.
Additionally, this uncaught exception from a non-
error_codeoverload manifested itself as anabort()with no useful logs. To aid in future investigations, I'm including a simple change to the filesystem test. Now, we wrap the whole test intry ... catchand print the contents of any exception before failing.