Windows: sceKernelStat on a self-referencing symlink throws in FillFileStat and aborts the process #6983
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 cadenasynyster on 2026-10-17T01:38:30Z.
On Windows,
sceKernelStaton a symbolic link that points to itself does not return an error:FillFileStatthrowsstd::runtime_errorand the process aborts.Exit code 0xC0000409.
On Linux,
mainreturnsENOENTfor the same call (per the table in #6648), and #6648 / #6942 change that toELOOP(0x8002003E), which is what FreeBSD returns.Repro
In an empty directory, create
loop -> loop(CreateSymbolicLinkA("loop", "loop", SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE); needs Developer Mode or elevation), then callsceKernelStat("loop", &st).Other results from the same run
main
f3263dfbf; identical with #6942 merged:sceKernelStat("loop")ELOOPsceKernelOpen("loop")EINVAL(0x80020016)ELOOPsceKernelOpen("loop/inside")ENOENT(0x80020002)ELOOPsceKernelOpen/sceKernelStat/sceKernelMkdir, 300-char name (cwd 70 chars)ENOENT(0x80020002)ENAMETOOLONGopen, 300-char nameFound by running #6942's
GuestPathErrors.cppon Windows with its symlinks created throughCreateSymbolicLinkA, since MinGW has nosymlink(). A control with #6942's test andHostErrnofiles on main'sOpen.cpp/Stdio.cppgives the same values and the same abort, so this predates both PRs.Windows 11 10.0.26200.9711 (NTFS), Developer Mode on, WinLibs GCC 15.2.0 posix UCRT r7, Release.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T01:48:07Z.
I have a focused follow-up draft for this case: it avoids throwing from the native stat path and translates the Windows failure to guest ELOOP. Before I treat it as ready, could you capture
errnoand_doserrnoimmediately after_wstat64fails for the self-link on your Windows setup? The draft currently mapsERROR_CANT_RESOLVE_FILENAME(1921) from_doserrno; Microsoft documents that as a Win32 error code, and documents_doserrnoas the OS-error equivalent for CRT I/O failures, but I have no Windows runtime to verify those exact values. The current draft is based on latest main and does not reuse code from #6648/#6942.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T02:24:57Z.
I opened #6992 with the non-throwing stat path and Windows self-loop regression assertion. The Linux focused target builds, but this host aborts at the CPU feature guard before test assertions. I have not verified
_doserrno == ERROR_CANT_RESOLVE_FILENAMEon the reported Windows runtime; the Windows PR check will provide the next validation opportunity.Imported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-17T19:19:39Z.
@MarcZX100 answering your question: on this setup
_wstat64does not fail on the self-link. The failure comes from theCreateFileWcall that follows it inDoStat.Standalone probe, compiled with the same WinLibs GCC 15.2.0 r7 (UCRT), doing the two
DoStatcalls in order onloop -> loop(absolute path, created withCreateSymbolicLinkW(..., SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE)):CreateFileWis called withFILE_READ_ATTRIBUTES,OPEN_EXISTINGandFILE_FLAG_BACKUP_SEMANTICS, as inDoStat. A relative_wstat64("loop")also returns 0 witherrnoand_doserrno0.So on #6992:
ERROR_CANT_RESOLVE_FILENAME->ELOOPmapping inWindowsFileTime::Failureis what produces the0x8002003Eresult here._doserrno == ERROR_CANT_RESOLVE_FILENAMEbranch after_wstat64is not reached on this setup, since_wstat64succeeds. I can't say whether other Windows/CRT versions fail there instead.Windows 11 10.0.26200.9711 (NTFS), Developer Mode on.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T20:19:04Z.
Thanks for the probe. That confirms the observed Windows path:
_wstat64succeeds for the self-link, thenCreateFileWfails withERROR_CANT_RESOLVE_FILENAME(1921), which the current #6992 head maps to guestELOOP. The earlier question about_doserrnoafter_wstat64is not relevant to this setup; #6992 also handles the laterCreateFileWfailure. The PR has Windows runtime validation and Linux runtime validation reported, with conventions/eligibility/report passing; hosted platform build jobs were skipped on its latest workflow run.Imported from boykopovar/AnyPS5. Originally posted by aarushkha on 2026-10-20T16:33:42Z.
The abort in the title looks fixed on
mainby #6992 (merged as32004dfa5).sceKernelStatnow goes throughFile::TryFillFileStatinstead of the throwingFillFileStat.DoStatmaps theCreateFileWfailureERROR_CANT_RESOLVE_FILENAME(1921) toELOOPinWindowsFileTime::Failure.GuestFilesystem.cpphas a Windows case that createsstat-loop -> stat-loopwithCreateSymbolicLinkWand requiressceKernelStatto return0x8002003E.I checked this by reading
main. I didn't run it. I also didn't check the other rows of the table (sceKernelOpenon the loop and the 300-characterENAMETOOLONGcases), so those may still need their own issue before this one is closed.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-20T19:56:22Z.
Status check on current main, run on Windows rather than read from the source. #6992 fixed the abort in the title, and this updates the other rows of the table above.
Windows 11 (NTFS, Developer Mode on), WinLibs GCC 15.2.0 r7 UCRT, Release, main fetched today. The link
loop -> loopwas created withCreateSymbolicLinkW(..., SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE)(it reported ok), because MinGW'sstd::filesystem::create_symlinkreturns "Function not implemented". The 300-character name is a single path component under the temp directory. A throwaway probe linked against libkernel and libc printed these rows:sceKernelStat("loop")sceKernelStat("loop/inside")sceKernelOpen("loop")openerrno 22sceKernelOpen("loop/inside")openerrno 20sceKernelStat,sceKernelOpen,sceKernelMkdirof a 300-character namestat,open,mkdirerrno 63So two rows from my original table no longer reproduce (the abort and the 300-character names), and two remain.
GuestFilesystem.cppruns its 300-character and loop checks only under#ifndef _WIN32, which is why main's own tests never exercised these rows on Windows. I did not re-measure the 300-character case with the original 70-character cwd; the probe used the temp directory as the parent.Not run: Linux, macOS, a name of exactly 255 or 256 characters, or any call other than the ones listed.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T20:11:03Z.
The remaining Windows
sceKernelOpen("loop/inside")row is now covered by #8655. The PR addsELOOPhandling for failed opens when a path resolves through the self-link and tests both the kernel API result and POSIXopenerrno. Its author reports the focused Windows CTest selection passing 75/75; hosted platform build jobs were skipped. The other rows in this issue remain separate.