libkernel: Windows lstat misreports symbolic links instead of throwing #2886
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Amoenus on 2026-10-10T17:40:27Z.
Confirmed Windows regression
On unchanged main
57f96fd2b36563e8380c603a92b1ef0d9d3a6aa4, Windowslstatreturns success with ordinary file/directory types for native symbolic links instead of reaching its explicit unsupported-link exception. Reproduced 5/5 runs. A fresh fetch still points main to that commit.Windows 11 Enterprise 26200, WinLibs r7 MinGW-w64 GCC 15.2.0, Release, BUILD_TESTING=ON, Developer Mode enabled for creating links. No Linux or console claim.
The merged implementation in PR #1624 explicitly intended Windows symbolic links to throw. In DoLstat, its guard uses
std::filesystem::is_symlink(std::filesystem::symlink_status(...)). On this toolchain, the native links report an ordinary file/directory type with no error. NativeGetFileAttributesWincludes FILE_ATTRIBUTE_REPARSE_POINT. The existing filesystem test exercises links only outside Windows.Reproduction
Build full system libraries from the pinned main using the normal Windows instructions. Make a fixture under the probe's working directory with an ordinary target file and directory, then native relative links:
Use native backslashes in Windows reparse targets; native target access is verified above. The probe below dynamically calls the actual patched
libkernel.prxexport DRGXpDDh8Ng and uses the repository's FileStat and APS5_VABI definitions. Its ordinary-file control must succeed before the link checks. No implementation change or game-specific adapter is used.Compile it from the source checkout with the same MinGW unwind setup used by the repository's runtime tests:
Run from the fixture's parent, with the absolute patched-library directory prepended to PATH, then pass that same directory and
lstat-fixtureas arguments. Using the repository's libc for unwinding matters when testing an exception-based fix.Observed
All five unchanged-main runs returned:
These are successful non-link classifications. The printed guest errno after success is not treated as an additional failure. A standalone host metadata probe also reports
is_symlink=0, error 0, and native reparse-point attributes. This does not depend on realpath being implemented.Suggested correction and local validation
A local diagnostic change checks GetFileAttributesW on Windows and throws when a successfully queried path has FILE_ATTRIBUTE_REPARSE_POINT. This rejects all Windows reparse points; it does not implement guest link metadata or host-to-guest target translation.
The expanded
guest_filesystemtest creates native file, directory, and dangling links, verifies the exact existing exception, and verifies that both guest errno and the entire output buffer remain untouched. Full system-library build passed; the test passed 5/5 runs, each below 0.1 s. Removing the guard made the expanded test fail; restoring it returned the test to 5/5. The same dynamic probe then received the exact exception for both links and verified untouched buffers. Conventions and test-registration checks passed. The Windows fixture requires Developer Mode or link creation privileges. No full-suite or Linux result is claimed.This was discovered while validating startup gaps for PPSA99902, but no lstat call by that title has been observed. Startup still stops on unresolved imports before guest entry. Searches for existing lstat/symlink Windows issues and PRs found the merged implementation and related work, but no open report of this guard failure. No new PR is being created while intake is paused.
AI-assisted investigation and local changes: Codex. Original game files are unchanged.