Skip to content

feat(zlib): implement sequential libSceZlib decompression - #1824

Merged
adriadam10 merged 4 commits into
boykopovar:mainfrom
Mouhand-Kaddo:feat/sce-zlib
Oct 9, 2026
Merged

adriadam10 merged 4 commits into
boykopovar:mainfrom
Mouhand-Kaddo:feat/sce-zlib

Conversation

@Mouhand-Kaddo

@Mouhand-Kaddo Mouhand-Kaddo commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

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

@Mouhand-Kaddo
Mouhand-Kaddo force-pushed the feat/sce-zlib branch 2 times, most recently from 1d3337c to aa3e4e4 Compare October 9, 2026 15:34
@popcoder565

Copy link
Copy Markdown
Contributor

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 d70b899 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

@Mouhand-Kaddo

Copy link
Copy Markdown
Contributor Author

Fixed the reported Windows abort in 913279b 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

Copy link
Copy Markdown
Collaborator

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 github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 9, 2026
Mouhand-Kaddo and others added 4 commits October 10, 2026 02:03
Resolve the missing system library with checksum-validating decompression. Add behavioral tests and document unsupported request semantics.
Remove the asynchronous unwind override so SysV exports use the project DWARF unwinding and avoid invalid SEH assembler directives.
Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

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

@adriadam10

Copy link
Copy Markdown
Collaborator

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 913279b. Merging once CI is green on the current head.

@adriadam10
adriadam10 merged commit c2f1139 into boykopovar:main Oct 9, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants