test(libc): run guest_fopen_errors on Windows #9583
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9583"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T03:15:55Z.
What
guest_fopen_errorswas registered only underif(UNIX)(libc/CMakeLists.txt:137). Its only POSIX dependency was::symlink, which it uses to build a self-referencing link. Everything it checks,fopen/freopen/fopen_sreturning ELOOP, ENAMETOOLONG, EISDIR, EINVAL and ENOENT, also exists on Windows.How:
GuestFopenErrors.cpp: on Windows the loop is made withCreateSymbolicLinkW(L"loop", L"loop", SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE). If that fails, the test requiresERROR_PRIVILEGE_NOT_HELD, prints the same "needs Developer Mode or administrator rights" line asGuestDirectory.cppandGuestAmpr.cpp, cleans up and exits 77.<unistd.h>is included only off Windows.libc/CMakeLists.txt: the test leavesif(UNIX). It getsSKIP_RETURN_CODE 77, so a CI account without symlink rights reports a skip, not a failure, plus the usual WIN32PATHprepend of the libc directory.Tested
ctest -R ^guest_fopen_errors$passes.GuestEloopmapping inHostErrno.cpp:26disabled, the test fails at line 69 (fopen("loop", "r")no longer reports ELOOP). Restored, it passes.tools/check_conventions.pypasses.Overlap (
tools/pr_overlap.py --branchplusgit merge-tree):guest_atomic_assertinside the sameif(UNIX)block, directly after the lines this PR moves out, so the two conflict textually. Resolution: keep #7851's five lines insideif(UNIX).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)guest_atomic_assertinsideif(UNIX)andguest_fopen_errorsoutside)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T03:45:38Z.
Review: CHANGES_REQUESTED
The Windows symlink handling is scoped to the test setup, requests the unprivileged-creation flag, and converts the specific permission failure into CTest's configured skip code with cleanup. The CMake registration and Windows
PATHsetup match neighboring tests. The current conventions check passes; the initial failure is superseded. Hosted relinker and related matrix checks pass; product builds are skipped. The Windows test and negative-control results are author-reported; I did not run them locally.The CMake hunk overlaps #7851: both edit the same
if(UNIX)registration area, and #7851 is still open. Your description already gives a safe resolution (keep #7851'sguest_atomic_assertregistration inside its UNIX guard while moving this test out). Please agree that order with its author and updateDepends onif either PR must land first; currently this checklist saysnone. If both can be merged independently after that explicit agreement, record the agreed order and keep the two registrations under their correct platform conditions.Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-22T08:13:12Z.
The Conventions check fails on the head of this PR (job 119617768332):
Fill in the pull request template: section 'What' is missing or empty, and the same forTestedandChecklist.Everything else in the matrix is green (relinker on all three OSes, relinker-asan, register-context, write-watch), and
python3 tools/check_conventions.py --base origin/mainprints the same three template findings locally. Filling in every line of.github/pull_request_template.md(What, Tested, Depends on, Unblocks, GPUs tested, AI-assisted, and tick the boxes) is all that appears to block CI.Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T09:20:35Z.
@fogydes thanks. That run was on the first head; the body has since been rewritten to the template and the Conventions job on the current head passes. @MarcZX10, the order with #7851 is agreed: @hypermoist confirmed on #7851 that neither PR depends on the other, and whichever merges second keeps
guest_atomic_assertinsideif(UNIX)andguest_fopen_errorsoutside it. It's now recorded in the checklist.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T10:23:06Z.
Review: CHANGES_REQUESTED
The #7851 overlap is now resolved by agreement: its author accepted the order-independent resolution, keeping
guest_atomic_assertinsideif(UNIX)and this test outside it. The checklist records that agreement, soDepends on: noneis accurate. The Windows symlink setup and permission-only skip path are also clear, and I found no test-logic issue in the diff. This head is 107 commits behind currentupstream/main. Please update it and rerun its checks before merge. Checks on exact headda2d201a1de2b495dcd4cc12c8594387eb34821a: -git diff --check upstream/main...HEAD: passed. -python tools/check_conventions.py --base upstream/main --head HEAD: passed. - Hosted eligibility, labels, report, conventions and relinker/matrix checks pass. Hosted Linux/Windows product jobs are skipped. - The changed Windows behavior was not run locally in this Linux workspace. The Windows 11 test and negative control in the description are author-reported.I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T12:46:32Z.
Independent Windows run of this PR, as data only. Machine: Windows 11 Enterprise 10.0.22621 (
CreateSymbolicLinkWsucceeds here, so the test does not take its skip path), Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Release. Head da2d201a1d was merged with #9584 ontomain8b3a6ba88d.cpu_topology(#9584) passes in 10 of 10 runs.guest_fopen_errorstimes out in 10 of 10 runs (ctest 20 s limit). It prints nothing: no check fails, and it never exits.The main thread is stuck inside libstdc++'s directory walk. The gdb stack, attached after 4 s:
This is the final
std::filesystem::remove_all(root, error). A standalone program with the same toolchain shows the cause. It createsloopwithCreateSymbolicLinkW(L"loop", L"loop", SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE)in a fresh directory:symlink_status("loop")reportsnot_foundandis_symlinkis false, because this libstdc++ does not see the reparse point.remove_allon the directory then never returns.DeleteFileW(L"loop")first letsremove_allfinish: 2 entries removed, no error.Each killed run also left an
anyps5-fopen-errors-<n>directory in%TEMP%, with the loop inside.rmdir /s /qremoves it.One way to fix it: on
_WIN32, delete the link withDeleteFileW(L"loop")while the root is still the current directory, before the cleanupremove_all, and also before the earlyremove_allin the exit-77 path if that path ever creates it. I have not tested that change in the test itself. Your Windows 11 26200 run passing may come from a different libstdc++ or Windows filesystem behaviour; I can't tell which from here.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T12:49:05Z.
Follow-up: I tried the suggested change in the test itself, on the same local merge (da2d201a1d + #9584 on
main8b3a6ba88d, same machine):With it,
ctest -R ^guest_fopen_errors$passes in 10 of 10 runs, and noanyps5-fopen-errors-*directory is left in%TEMP%. Without it, the same build timed out in 10 of 10 runs. The ELOOP checks themselves are unchanged. The link is still the current directory'sloopat that point, becausecurrent_pathhas not moved yet.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T13:32:07Z.
Review: DISMISSED
The Windows test has a reproducible cleanup hang on this exact head.
main()creates the self-referentialloopsymlink inEnterFreshRoot(), runs the checks, then changes to the temp parent and callsstd::filesystem::remove_all(root)atGuestFopenErrors.cpp:120-121. An independent Windows/MinGW run reports this head timing out 10/10 becauseremove_alldoes not recognize the reparse point and loops in the directory walk. The same reviewer addedDeleteFileW(L"loop")before changing the current directory and reports 10/10 passes with no leftover temp directories. Please remove the link explicitly on_WIN32while the test is still in the fresh root, check that removal succeeds, then leave the existingremove_allcleanup in place. The permission-denied skip path is reached only when link creation fails, so it should not contain a created link.I ran
g++ -std=c++20 -Wall -Wextra -Werror -fsyntax-only -Icore/libs core/libs/tests/GuestFopenErrors.cppand the correspondingx86_64-w64-mingw32-g++command on exact headda2d201a1de2b495dcd4cc12c8594387eb34821a; both pass. These are syntax checks only; I cannot execute the Windows binary here. Hosted product jobs are skipped. The independent Windows timeout/fix runs are the runtime evidence for this blocker.Separately, I withdraw my earlier generic intake objection: your contribution-count eligibility means the queue-based hold does not apply. The merge-order agreement with #7851 is already recorded. The branch still needs an update to current upstream main (
8b3e39832af85f404c6195418d11b3e1ebd1924d, 150 commits ahead of this head), followed by the focused Windows run. Current-main diff-check and conventions pass.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-25T04:35:13Z.
Review: APPROVED
Reviewed
da2d201a1de2b495dcd4cc12c8594387eb34821aagainst6ef5a1c4c92272598b18adeb9b5414112f8d15ed. No actionable findings in this focused review.Source review: Inspected the complete platform/registration change and fixture cleanup. Windows uses CreateSymbolicLinkW for the self-referential file link; privilege failure is explicitly reported as skip 77 after leaving and deleting the fresh fixture directory. CTest now recognizes that skip and adds the Windows runtime path. Existing fopen/reopen/error assertions and non-Windows creation remain unchanged.
Validation: Windows / GCC 15.2: exact head syntax compilation passed; baseline fails because ::symlink is unavailable. The submitted test linked against existing local development libc/libkernel and returned 77 with the expected privilege message. That compatibility execution verifies the skip path, not the fopen assertions or a pinned runtime build. Conventions, whitespace and registration passed. Effective hosted relinker/ASan and metadata checks succeeded; product jobs were skipped.
Scope: Bounded Windows fixture/CTest portability change. Successful symlink-capable fopen execution remains unverified locally; no privileges/settings were changed and no game ran.