Repository navigation
fix(libc): check long host directories through the verbatim path on Windows - #25001
Merged
oneandonlydean merged 1 commit intoNov 21, 2026
Merged
Conversation
…indows
RequireHostDirectory called std::filesystem::status on the plain host
path. Past MAX_PATH, Windows reports such a path as missing, so resolving
".." from a long working directory threw "Guest path component is not a
directory" and chdir("..") failed with ENOENT. The host path and its
prefixes are now checked through NativeVerbatimPath_nid_no_patch, as
IsDirectory already does.
CheckRawGetcwdPathLimit now also runs on Windows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PrivacyOnion
approved these changes
Nov 21, 2026
PrivacyOnion
left a comment
Contributor
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 7302b6d421:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_kernel_sys_testsbuilt cleanly. - CTest (
guest_kernel_sys):1/1 Test #962: guest_kernel_sys ................. Passed 0.33 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libc/src/General.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #962: guest_kernel_sys ................. Passed 0.20 sec 100% tests passed, 0 tests failed out of 1 - Code reading:
- Verified that RequireHostDirectory in core/libs/prx/libc/src/General.cpp applies NativeVerbatimPath_nid_no_patch to both the leaf host path and every ancestor prefix path under _WIN32, ensuring long paths (>MAX_PATH) correctly query directory status via verbatim path syntax.
- Checked fallback error-handling behavior in hostStatus lambda: when NativeVerbatimPath_nid_no_patch encounters an error (verbatimError is set), it cleanly falls back to querying the original path without throwing or corrupting failure error_code.
- Verified that error categorization (is_directory vs exists leading to not_a_directory or no_such_file_or_directory) properly updates error and propagates expected POSIX errors to callers.
- Checked re-enabling CheckRawGetcwdPathLimit on Windows in core/libs/tests/GuestKernelSys.cpp, confirming it verifies getcwd and chdir path limits with long host directories without platform regressions.
- Audited memory safety, pointer bounds, concurrency locks, and AGENTS.md conventions (no disallowed comments, no forbidden stubs, clean gates).
Looks Good To Me
12 tasks done
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.
What
On Windows,
chdir("..")fails withENOENTwhen the guest working directory's host path is longer thanMAX_PATH.RequireHostDirectory(core/libs/prx/libc/src/General.cpp) checks the resolved host directory, and onENOENTits prefixes, withstd::filesystem::statuson the plain host path. PastMAX_PATH, Windows reports that path as missing unless the process is long-path aware andLongPathsEnabledis set. The test executables have nolongPathAwaremanifest entry; onlyrelinker.manifesthas one. So resolving..from a long working directory throwsGuest path component is not a directory, and the guest getsENOENT.The rest of the path code already goes through
NativeVerbatimPath_nid_no_patch(for exampleIsDirectorya few lines below andSetLongWorkingDirectory). This PR makesRequireHostDirectorydo the same for the host path and for its prefixes. Non-Windows builds are unchanged.CheckRawGetcwdPathLimitinguest_kernel_syswas skipped on Windows (#ifndef _WIN32since 58ab562, with no reason recorded). This PR runs it on Windows too. It is the regression test: onmainit fails atRequire(chdir_nid_postfix("..") == 0)right after the 1023-byte working-directory case. The host path there is 1060 characters.Related: #22932 fixes the same test family on macOS, in
HostPath, a different function. The two changes don't overlap.Tested
Windows 11 Pro 10.0.26200, WinLibs GCC 15.2.0 r7 (UCRT), Release,
BUILD_TESTING=ON, onmain9950ae3.LongPathsEnabledis 1 on this machine. The test still fails without the fix, because the test executables are not long-path aware.guest_kernel_sys(3 runs)ctest -E '^agc' -j 8main9950ae3main+ the test enabled on Windows, no fixKernel sys check failed at line 1469 (guest errno 2)python3 tools/check_conventions.py --base origin/mainpasses.Not tested: Linux and macOS. The change only compiles on Windows, and the test change only removes the Windows skip.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code