feat(zlib): implement sequential libSceZlib decompression #1824

Merged
Mouhand-Kaddo merged 4 commits from upstream-pr/1824 into main 2026-10-09 22:54:11 +00:00
Mouhand-Kaddo commented 2026-10-08 20:35:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-08T20:35:25Z.


What

Add the five libSceZlib exports required by Prospero Explorer in #1578. Reuse the existing JPEG dependency's bundled zlib for bounded RFC1950 decompression with checksum validation. Submission completes immediately and produces a request ID for the wait/result lifecycle.

This is partial sequential support. Timed waits, multiple outstanding requests, repeated result retrieval and finalization with unread results throw. SharpProspero supplies the caller ABI and output limits. Error-status mappings follow shadPS4. Conflicting PS4 signatures and unverified PS5 scheduling, scratch-buffer and result semantics are listed in TechnicalDebt.

Tested

Linux x86-64. guest_zlib passes independent compressed fixtures, plaintext checks, checksum/truncation failures, exact and insufficient capacity, alignment, output canaries, request IDs and lifecycle guards. Standalone ASan/UBSan passes. Existing JPEG and PNG decoder tests also pass.

Native Windows 11 Pro (build 26300), MinGW-w64 GCC 15.2.0 (WinLibs x86_64-ucrt-posix-seh r7), Release. Reproduced the reported abort at sceZlibInitialize(nullptr, 1) before removing the test's -fasynchronous-unwind-tables override. At commit 913279b8, guest_zlib passes five consecutive runs; windows_exceptions and the four JPEG/PNG decoder tests also pass. The rebuilt test uses DWARF unwind frames and __gxx_personality_v0.

WSL Ubuntu 24.04 x86-64, GCC 13.3.0, Release, at the same fixed commit. guest_zlib passes five consecutive runs; exception_runtime, exception_personality, exception_c_cleanup and the four JPEG/PNG decoder tests also pass. The Linux compile command contains neither Windows unwind flag. Repository conventions and test-registration checks pass.

A local consumer compiled for FreeBSD against ps5-payload-sdk v0.43 headers passes through the patched NID exports. It checks 64-bit request IDs, 32-bit results and output bytes. Host z_stream and errno never cross the Sony API. SDK tooling is outside the repository. No PS5 execution was performed.

The released Prospero Explorer v1.0 binary previously stopped at missing libSceZlib.prx. With this module it reaches the next unresolved madvise import. All five Zlib imports resolve. This does not make the title run.

Independent code review passes both standards and spec, with no actionable findings.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except permitted namespace endings
  • Unsupported paths throw and known gaps are listed in TechnicalDebt
  • No investigation notes, images or SDK tooling added to the repository
  • Reuses existing bundled dependencies
  • Behaviour applies to any caller of the supported API subset
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4792484435 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1824). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-08T20:35:25Z. --- ### What Add the five `libSceZlib` exports required by Prospero Explorer in #1578. Reuse the existing JPEG dependency's bundled zlib for bounded RFC1950 decompression with checksum validation. Submission completes immediately and produces a request ID for the wait/result lifecycle. This is partial sequential support. Timed waits, multiple outstanding requests, repeated result retrieval and finalization with unread results throw. [SharpProspero](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Interop/Compression/Zlib.cs) supplies the caller ABI and output limits. Error-status mappings follow shadPS4. Conflicting PS4 signatures and unverified PS5 scheduling, scratch-buffer and result semantics are listed in TechnicalDebt. ### Tested Linux x86-64. `guest_zlib` passes independent compressed fixtures, plaintext checks, checksum/truncation failures, exact and insufficient capacity, alignment, output canaries, request IDs and lifecycle guards. Standalone ASan/UBSan passes. Existing JPEG and PNG decoder tests also pass. Native Windows 11 Pro (build 26300), MinGW-w64 GCC 15.2.0 (WinLibs x86_64-ucrt-posix-seh r7), Release. Reproduced the reported abort at `sceZlibInitialize(nullptr, 1)` before removing the test's `-fasynchronous-unwind-tables` override. At commit `913279b8`, `guest_zlib` passes five consecutive runs; `windows_exceptions` and the four JPEG/PNG decoder tests also pass. The rebuilt test uses DWARF unwind frames and `__gxx_personality_v0`. WSL Ubuntu 24.04 x86-64, GCC 13.3.0, Release, at the same fixed commit. `guest_zlib` passes five consecutive runs; `exception_runtime`, `exception_personality`, `exception_c_cleanup` and the four JPEG/PNG decoder tests also pass. The Linux compile command contains neither Windows unwind flag. Repository conventions and test-registration checks pass. A local consumer compiled for FreeBSD against ps5-payload-sdk v0.43 headers passes through the patched NID exports. It checks 64-bit request IDs, 32-bit results and output bytes. Host z_stream and errno never cross the Sony API. SDK tooling is outside the repository. No PS5 execution was performed. The released Prospero Explorer v1.0 binary previously stopped at missing `libSceZlib.prx`. With this module it reaches the next unresolved `madvise` import. All five Zlib imports resolve. This does not make the title run. Independent code review passes both standards and spec, with no actionable findings. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except permitted namespace endings - [x] Unsupported paths throw and known gaps are listed in TechnicalDebt - [x] No investigation notes, images or SDK tooling added to the repository - [x] Reuses existing bundled dependencies - [x] Behaviour applies to any caller of the supported API subset - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-09 08:56:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T08:56:00Z.


Progress report (b271417 → 810eda2)

📈 System libraries: 85.63% (+0.02%, +5 implemented functions)

✅ 5 implemented
Library Name
libSceZlib sceZlibFinalize
libSceZlib sceZlibGetResult
libSceZlib sceZlibInflate
libSceZlib sceZlibInitialize
libSceZlib sceZlibWaitForDone
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077723432 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1824#issuecomment-6077723432). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T08:56:00Z. --- <!-- progress-report --> ### Progress report (b271417 → 810eda2) 📈 **System libraries**: 85.63% (+0.02%, +5 implemented functions) <details> <summary>✅ 5 implemented</summary> | Library | Name | | - | - | | libSceZlib | `sceZlibFinalize` | | libSceZlib | `sceZlibGetResult` | | libSceZlib | `sceZlibInflate` | | libSceZlib | `sceZlibInitialize` | | libSceZlib | `sceZlibWaitForDone` | </details>
popcoder565 commented 2026-10-09 15:44:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:44:54Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 1d3337c4, merged onto main d70b8998 in one build with 38 other PRs that had no Windows run. The current head aa3e4e4c is a rebase with the same zlib files, including the -fasynchronous-unwind-tables block below.

guest_zlib aborts on Windows in every run:

[libc] unhandled exception 'St13runtime_error' thrown from ...
terminate called after throwing an instance of 'std::runtime_error'
  what():  sceZlibInitialize: invalid work buffer
  • This is the first RequireThrows, sceZlibInitialize(nullptr, 1).
  • The test is compiled with -fasynchronous-unwind-tables on MinGW, so GCC emits SEH unwind data (__gxx_personality_seh0) instead of DWARF frames.
  • The exception is raised through libc's DWARF unwinder. It finds no handler in the test, because the test's .ehfram section is empty (4 bytes).

Removing that block fixes it. guest_zlib then passes 5 of 5, and the full suite in that build passes (519 of 519):

     configure_windows_unwind(guest_zlib_tests)
-    if(MINGW)
-        target_compile_options(guest_zlib_tests PRIVATE -fasynchronous-unwind-tables)
-    endif()

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6084247068 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1824#issuecomment-6084247068). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T15:44:54Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `1d3337c4`, merged onto `main` d70b8998 in one build with 38 other PRs that had no Windows run. The current head `aa3e4e4c` is a rebase with the same zlib files, including the `-fasynchronous-unwind-tables` block below. **`guest_zlib` aborts on Windows in every run:** ``` [libc] unhandled exception 'St13runtime_error' thrown from ... terminate called after throwing an instance of 'std::runtime_error' what(): sceZlibInitialize: invalid work buffer ``` - This is the first `RequireThrows`, `sceZlibInitialize(nullptr, 1)`. - The test is compiled with `-fasynchronous-unwind-tables` on MinGW, so GCC emits SEH unwind data (`__gxx_personality_seh0`) instead of DWARF frames. - The exception is raised through libc's DWARF unwinder. It finds no handler in the test, because the test's `.ehfram` section is empty (4 bytes). Removing that block fixes it. `guest_zlib` then passes 5 of 5, and the full suite in that build passes (519 of 519): ```diff configure_windows_unwind(guest_zlib_tests) - if(MINGW) - target_compile_options(guest_zlib_tests PRIVATE -fasynchronous-unwind-tables) - endif() ``` _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
Mouhand-Kaddo commented 2026-10-09 16:08:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-09T16:08:23Z.


Fixed the reported Windows abort in 913279b89476faa3f1b2f48093079170f17d05fe by removing the guest_zlib_tests override for -fasynchronous-unwind-tables. The test now inherits the project's DWARF unwind configuration.

I reproduced the abort at sceZlibInitialize(nullptr, 1) before the change. The original executable imported __gxx_personality_seh0 and had a four-byte .ehfram section. After the change, it imports __gxx_personality_v0 and has populated DWARF unwind frames.

Verification of the fixed commit:

  • Native Windows 11 Pro, build 26300, MinGW-w64 GCC 15.2.0 (WinLibs x86_64-ucrt-posix-seh r7), Release: guest_zlib passed five consecutive runs. windows_exceptions, decoder_jpeg, guest_jpeg_dec, decoder_png and guest_png_dec all passed.
  • WSL Ubuntu 24.04 x86-64, GCC 13.3.0, Release: guest_zlib passed five consecutive runs. exception_runtime, exception_personality, exception_c_cleanup and the four JPEG/PNG tests above all passed. The Linux compile command contains neither Windows unwind flag.

Repository conventions and test-registration checks passed. The PR description now includes the Windows and WSL results. This fix and verification were AI-assisted.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6084639799 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1824#issuecomment-6084639799). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-09T16:08:23Z. --- Fixed the reported Windows abort in 913279b89476faa3f1b2f48093079170f17d05fe by removing the `guest_zlib_tests` override for `-fasynchronous-unwind-tables`. The test now inherits the project's DWARF unwind configuration. I reproduced the abort at `sceZlibInitialize(nullptr, 1)` before the change. The original executable imported `__gxx_personality_seh0` and had a four-byte `.ehfram` section. After the change, it imports `__gxx_personality_v0` and has populated DWARF unwind frames. Verification of the fixed commit: - Native Windows 11 Pro, build 26300, MinGW-w64 GCC 15.2.0 (WinLibs x86_64-ucrt-posix-seh r7), Release: `guest_zlib` passed five consecutive runs. `windows_exceptions`, `decoder_jpeg`, `guest_jpeg_dec`, `decoder_png` and `guest_png_dec` all passed. - WSL Ubuntu 24.04 x86-64, GCC 13.3.0, Release: `guest_zlib` passed five consecutive runs. `exception_runtime`, `exception_personality`, `exception_c_cleanup` and the four JPEG/PNG tests above all passed. The Linux compile command contains neither Windows unwind flag. Repository conventions and test-registration checks passed. The PR description now includes the Windows and WSL results. This fix and verification were AI-assisted.
adriadam10 commented 2026-10-09 21:05:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:05:33Z.


Checked the five exports against SharpProspero (ABI, 64 KiB / 2 KiB limits) and shadPS4 (error values, status mapping); full build and ctest are green on current main (guest_zlib included).

Added one commit: a TechnicalDebt note that shadPS4 also requires the output length to be a multiple of 2 KiB and returns 0x81120016 for invalid arguments, while this PR accepts any length up to 64 KiB (as SharpProspero documents only the pointer alignment) and throws. Rebased onto current main.

Merging once CI is green on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089248699 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1824#issuecomment-6089248699). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T21:05:33Z. --- Checked the five exports against SharpProspero (ABI, 64 KiB / 2 KiB limits) and shadPS4 (error values, status mapping); full build and ctest are green on current main (`guest_zlib` included). Added one commit: a TechnicalDebt note that shadPS4 also requires the output length to be a multiple of 2 KiB and returns `0x81120016` for invalid arguments, while this PR accepts any length up to 64 KiB (as SharpProspero documents only the pointer alignment) and throws. Rebased onto current main. Merging once CI is green on the new head.
github-actions[bot] commented 2026-10-09 22:28:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T22:28:49Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1873 docs/dev/TechnicalDebt.md L251
#1924 docs/dev/TechnicalDebt.md L251
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090307293 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1824#issuecomment-6090307293). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T22:28:49Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1873 | `docs/dev/TechnicalDebt.md` [L251](https://github.com/boykopovar/AnyPS5/blob/64fe74399528c84fd74c3f736e632f89f4a7f211/docs/dev/TechnicalDebt.md#L251) | | | | #1924 | `docs/dev/TechnicalDebt.md` [L251](https://github.com/boykopovar/AnyPS5/blob/64fe74399528c84fd74c3f736e632f89f4a7f211/docs/dev/TechnicalDebt.md#L251) | | |
adriadam10 commented 2026-10-09 22:54:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:54:07Z.


Checked the five exports against SharpProspero (ABI, limits) and shadPS4 (error values), the TechnicalDebt entry, and the template. Full build and ctest are green on current main (guest_zlib included), and the test fails to build without the change. The Windows abort popcoder565 reported is fixed in 913279b8. Merging once CI is green on the current head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090640876 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1824#issuecomment-6090640876). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T22:54:07Z. --- Checked the five exports against SharpProspero (ABI, limits) and shadPS4 (error values), the TechnicalDebt entry, and the template. Full build and ctest are green on current main (`guest_zlib` included), and the test fails to build without the change. The Windows abort popcoder565 reported is fixed in 913279b8. Merging once CI is green on the current head.
Sign in to join this conversation.
No reviewers
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!1824
No description provided.