libc: fopen aborts on the movie directory scan in PPSA99902 (Windows, conditional integration) #4814

Closed
opened 2026-10-12 22:43:40 +00:00 by Amoenus · 2 comments
Amoenus commented 2026-10-12 22:43:40 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-12T22:43:40Z.


Observed stop

Sonic Unleashed Recompiled, PPSA99902 / 01.003.000, exits before rendering when its directory scan attempts:

[fopen-validation] filename=/app0/ressources/game/movie/Inspire mode=rb
fopen_nid_postfix: open failed: ".../app0/ressources/game/movie/Inspire": Permission denied
FATAL: abort() (SIGABRT)

Inspire is an existing directory. A refreshed conditional integration 6cc5beb7f, based on main 5f01c8082, reproduces the stop in 9.998 seconds, exit 0xC0000409, no timeout or frames. A second replay with verified scalar logging in libc only confirms mode rb and reproduces the same stop in 9.626 seconds. The failed first observer preparation did not contain the logging marker and is not mode evidence.

This is conditional title validation, not a whole-main title launch. Original executable/bundled libc, all baseline runtime files, converted guest module and saved user data were restored and verified after each replay. No proprietary assets/code/captures attached.

Source and contract

The integration makes no change to core/libs/prx/libc/src/FileAndHeap.cpp. That file is also unchanged between main 5f01c8082 and later main 43e3a70f8. Its Windows OpenNative calls CreateFileW with FILE_ATTRIBUTE_NORMAL; Microsoft's directory-handle documentation requires FILE_FLAG_BACKUP_SEMANTICS for directories. The mapped failure reaches fopen_nid_postfix, whose current failure branch returns null only for ENOENT or an exclusive EEXIST, searches sibling filenames, and otherwise throws.

FreeBSD 11.4 fopen(3), pinned source specifies a null result plus errno when opening fails. A normal backend open failure therefore must not become an uncaught host exception. Whether Windows should model a successful read-only directory stream, as FreeBSD can, is a separate semantic question; a null return for this host failure does not prove console directory-stream equivalence.

Native regression and proposed fix

On unchanged production main 43e3a70f8143f014f621c48abbdb137fffd7346e, adding a temporary-directory regression to the existing file_streams fixture reproduces the uncaught failure: CTest reports exit 0xC0000409 in 0.44 seconds. The focused candidate removes sibling-name probing and the exception branch, returning null with the native backend errno for failed opens. The initial fixture then passes 20 consecutive executions (0.01–0.12 seconds observed per execution), retaining the existing successful stream, Unicode/delete-sharing, append/exclusive-create, missing-file and invalid-argument checks.

Existing upstream solution and next validation

PR #4822, by MarcZX100, now implements the same general failed-open NULL/errno correction, with a directory regression (rb on Windows, wb on POSIX). I inspected exact head 77ede919c460fbe1acbfe2bf4d927fb3db0a6416; the author reports Debian 12 / GCC12.2 Release validation in their comment. Those Linux results are the author's report, not my local execution.

Independent Windows validation of #4822's exact head now passes: all five filesystem/stream groups ×20 (100 executions, no skips). Keeping its regression fixture unchanged while rebuilding main 43e3a70f8's FileAndHeap.cpp reproduces the permission-denied abort; restoring the PR implementation passes. Native target builds, conventions and diff checks pass. The complete commands, OS/toolchain, observed durations and scope are in our validation comment. Tracked source is restored/clean. Full Windows build/libraries and NVIDIA suite now pass (1011 passed /0 failed /8 skipped of1019; maximum22.809s). Conditional title comparison now completed: Sonic Unleashed Recompiled, PPSA99902 / 01.003.000, same fixed f609 conversion and frozen 6cc runtime. Fresh control aborts at the existing Inspire directory / fopen permission-denied exception after 10.126s. Replacing only libc.prx with the integration build of your exact FileAndHeap.cpp (retaining the game's private prerequisite exports) changes the observed abort to poll: descriptor 3 is not a socket / descriptor5 on another thread after 9.981s. All other123 runtime-library hashes and executable hash match. Both runs exit0xC0000409 with no frames or timeout; originals, runtime, converted guest and user data are restored/hash-verified. This removes the observed fopen exception from the replay; it does not establish rendering, gameplay or unchanged whole-main startup. The next poll guard is already tracked in #3521, with overlapping open #3644/#3649; the follow-up observer confirms read pipes, and the #3644 kernel-only comparison now renders startup and reaches the existing private MSAA guard after789.240s. Originals/runtime/user data are restored; gameplay and whole-main startup remain unverified.

Our independently prepared focused fork candidate 1ed378e959 also passes the final strengthened fixture and the same five groups ×20 on Windows. It adds rb/wb/ab/r+b directory error checks and records the unmodeled Windows/FreeBSD directory-stream difference. The experimental adaptation 14f4611c69 is preserved in the fork with an identical FileAndHeap.cpp; it is preserved as an intermediate branch; the exact-#4822 adaptation at 088e3512b supplies the libc-only comparison above. #4822 is the upstream solution to validate; our next own PR will use another topic. Original assets, baseline runtime and user data remain preserved. AI-assisted: Codex.

The read-only directory-stream difference remains separate technical debt: returning null for Windows EACCES follows the failed-open contract, but does not implement successful FreeBSD-style directory streams or prove console behavior. AI-assisted: Codex.

Environment: Windows 11 Enterprise 26200, WinLibs GCC 15.2.0 r7 / Release, NVIDIA RTX5080. The refreshed integration passes its full native NVIDIA suite (1027 passed / 0 failed / 8 skipped of 1035) and 15 selected groups five times; these existing tests did not catch this title stop. Related #4735 is an fdopen append error, and closed #2329/#2588 concern UTF-8 paths; searches for fopen/directory, Inspire and fopen/EACCES found no report of this stop. No cause bisect against the older integration is claimed.

Shared title progress: #4443. AI-assisted: yes (Codex); author responsible.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5821480497 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4814). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-12T22:43:40Z. --- ### Observed stop Sonic Unleashed Recompiled, **PPSA99902 / 01.003.000**, exits before rendering when its directory scan attempts: ```text [fopen-validation] filename=/app0/ressources/game/movie/Inspire mode=rb fopen_nid_postfix: open failed: ".../app0/ressources/game/movie/Inspire": Permission denied FATAL: abort() (SIGABRT) ``` `Inspire` is an existing directory. A refreshed conditional integration [6cc5beb7f](https://github.com/Amoenus/AnyPS5/commit/6cc5beb7f7e2558c70054ee1fb2882d2c2db7d74), based on main `5f01c8082`, reproduces the stop in 9.998 seconds, exit `0xC0000409`, no timeout or frames. A second replay with verified scalar logging in libc only confirms mode `rb` and reproduces the same stop in 9.626 seconds. The failed first observer preparation did not contain the logging marker and is not mode evidence. **This is conditional title validation, not a whole-main title launch.** Original executable/bundled libc, all baseline runtime files, converted guest module and saved user data were restored and verified after each replay. No proprietary assets/code/captures attached. ### Source and contract The integration makes **no change to `core/libs/prx/libc/src/FileAndHeap.cpp`**. That file is also unchanged between main `5f01c8082` and later main `43e3a70f8`. Its Windows `OpenNative` calls `CreateFileW` with `FILE_ATTRIBUTE_NORMAL`; [Microsoft's directory-handle documentation](https://learn.microsoft.com/en-us/windows/win32/fileio/obtaining-a-handle-to-a-directory) requires `FILE_FLAG_BACKUP_SEMANTICS` for directories. The mapped failure reaches `fopen_nid_postfix`, whose current failure branch returns null only for ENOENT or an exclusive EEXIST, searches sibling filenames, and otherwise throws. [FreeBSD 11.4 fopen(3), pinned source](https://github.com/freebsd/freebsd-src/blob/5d9a4a50c59f296257bb548116b86cc760be71f0/lib/libc/stdio/fopen.3) specifies a null result plus errno when opening fails. A normal backend open failure therefore must not become an uncaught host exception. Whether Windows should model a successful read-only directory stream, as FreeBSD can, is a separate semantic question; a null return for this host failure does not prove console directory-stream equivalence. ### Native regression and proposed fix On unchanged production main `43e3a70f8143f014f621c48abbdb137fffd7346e`, adding a temporary-directory regression to the existing `file_streams` fixture reproduces the uncaught failure: CTest reports exit `0xC0000409` in 0.44 seconds. The focused candidate removes sibling-name probing and the exception branch, returning null with the native backend errno for failed opens. The initial fixture then passes **20 consecutive executions** (0.01–0.12 seconds observed per execution), retaining the existing successful stream, Unicode/delete-sharing, append/exclusive-create, missing-file and invalid-argument checks. ### Existing upstream solution and next validation [PR #4822](https://github.com/boykopovar/AnyPS5/pull/4822), by MarcZX100, now implements the same general failed-open NULL/errno correction, with a directory regression (`rb` on Windows, `wb` on POSIX). I inspected exact head `77ede919c460fbe1acbfe2bf4d927fb3db0a6416`; the author reports Debian 12 / GCC12.2 Release validation in [their comment](https://github.com/boykopovar/AnyPS5/issues/4814#issuecomment-6134215644). Those Linux results are the author's report, not my local execution. **Independent Windows validation of #4822's exact head now passes:** all five filesystem/stream groups ×20 (100 executions, no skips). Keeping its regression fixture unchanged while rebuilding main `43e3a70f8`'s `FileAndHeap.cpp` reproduces the permission-denied abort; restoring the PR implementation passes. Native target builds, conventions and diff checks pass. The complete commands, OS/toolchain, observed durations and scope are in [our validation comment](https://github.com/boykopovar/AnyPS5/pull/4822#issuecomment-6134583756). Tracked source is restored/clean. Full Windows build/libraries and NVIDIA suite now pass (1011 passed /0 failed /8 skipped of1019; maximum22.809s). **Conditional title comparison now completed:** Sonic Unleashed Recompiled, PPSA99902 / 01.003.000, same fixed f609 conversion and frozen 6cc runtime. Fresh control aborts at the existing `Inspire` directory / `fopen` permission-denied exception after 10.126s. Replacing **only libc.prx** with the integration build of your exact `FileAndHeap.cpp` (retaining the game's private prerequisite exports) changes the observed abort to `poll: descriptor 3 is not a socket` / descriptor5 on another thread after 9.981s. All other123 runtime-library hashes and executable hash match. Both runs exit0xC0000409 with no frames or timeout; originals, runtime, converted guest and user data are restored/hash-verified. This removes the observed fopen exception from the replay; it does not establish rendering, gameplay or unchanged whole-main startup. The next poll guard is already tracked in [#3521](https://github.com/boykopovar/AnyPS5/issues/3521), with overlapping open #3644/#3649; the follow-up observer confirms read pipes, and the [#3644 kernel-only comparison](https://github.com/boykopovar/AnyPS5/pull/3644#issuecomment-6135121778) now renders startup and reaches the existing private MSAA guard after789.240s. Originals/runtime/user data are restored; gameplay and whole-main startup remain unverified. Our independently prepared [focused fork candidate `1ed378e959`](https://github.com/Amoenus/AnyPS5/commit/1ed378e95973b905579094fd4f25bb06317d0388) also passes the final strengthened fixture and the same five groups ×20 on Windows. It adds rb/wb/ab/r+b directory error checks and records the unmodeled Windows/FreeBSD directory-stream difference. The [experimental adaptation `14f4611c69`](https://github.com/Amoenus/AnyPS5/commit/14f4611c69b5dc56b8a11dd2e50920e0366eb923) is preserved in the fork with an identical `FileAndHeap.cpp`; it is preserved as an intermediate branch; the exact-#4822 adaptation at `088e3512b` supplies the libc-only comparison above. #4822 is the upstream solution to validate; our next own PR will use another topic. Original assets, baseline runtime and user data remain preserved. AI-assisted: Codex. The read-only directory-stream difference remains separate technical debt: returning null for Windows EACCES follows the failed-open contract, but does not implement successful FreeBSD-style directory streams or prove console behavior. AI-assisted: Codex. Environment: Windows 11 Enterprise 26200, WinLibs GCC 15.2.0 r7 / Release, NVIDIA RTX5080. The refreshed integration passes its full native NVIDIA suite (1027 passed / 0 failed / 8 skipped of 1035) and 15 selected groups five times; these existing tests did not catch this title stop. Related #4735 is an fdopen append error, and closed #2329/#2588 concern UTF-8 paths; searches for fopen/directory, Inspire and fopen/EACCES found no report of this stop. No cause bisect against the older integration is claimed. Shared title progress: [#4443](https://github.com/boykopovar/AnyPS5/discussions/4443). AI-assisted: yes (Codex); author responsible.
MarcZX10 commented 2026-10-12 22:57:25 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T22:57:25Z.


I reproduced the host-independent failure path with an existing directory fixture: file_streams aborts on current main with the uncaught fopen_nid_postfix: open failed ... Is a directory exception, and passes with the change.

The fix is in PR #4822: https://github.com/boykopovar/AnyPS5/pull/4822. On Debian 12 x86-64 / GCC 12.2 Release, file_streams, guest_fiopen, guest_standard_streams, guest_directory and guest_filesystem pass (5/5), and conventions pass. The regression uses rb on Windows (the reported case) and wb on POSIX, where reading a directory is allowed. Hosted Windows checks are still pending; I have not run the title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6134215644 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4814#issuecomment-6134215644). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T22:57:25Z. --- I reproduced the host-independent failure path with an existing directory fixture: `file_streams` aborts on current `main` with the uncaught `fopen_nid_postfix: open failed ... Is a directory` exception, and passes with the change. The fix is in PR #4822: https://github.com/boykopovar/AnyPS5/pull/4822. On Debian 12 x86-64 / GCC 12.2 Release, `file_streams`, `guest_fiopen`, `guest_standard_streams`, `guest_directory` and `guest_filesystem` pass (5/5), and conventions pass. The regression uses `rb` on Windows (the reported case) and `wb` on POSIX, where reading a directory is allowed. Hosted Windows checks are still pending; I have not run the title.
oneandonlydean commented 2026-10-14 02:41:14 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:41:14Z.


Closing: fixed on main by #4822 (fopen returns the native open error instead of aborting). If it still happens on current main, comment here with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159683608 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/4814#issuecomment-6159683608). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:41:14Z. --- Closing: fixed on main by #4822 (fopen returns the native open error instead of aborting). If it still happens on current main, comment here with the title ID and the log line.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#4814
No description provided.