feat(libSceNKWebKitRequirements): implement the zlib exports #14374
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14374"
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 justdoston on 2026-11-01T10:48:31Z.
What
Implements the ten zlib exports of libSceNKWebKitRequirements:
deflateInit2_,deflate,deflateReset,deflateEnd,deflateBound,inflateInit2_,inflate,inflateReset,inflateEndanduncompress(libSceNKWebKitRequirements 0/165 → 10/165; libraries 8981 → 8991 of 34237, 26.23% → 26.26%).fKk7unahoVM,gnWUEMlAxZY,mhD00YrjSbg,Z0pL-Tae6N4,VCIAd+nrADw,MM-aVBE7p-A,dbDvWQUel6A,sUO777nQSTQ,XVx6JyC0Mv4,ROw6faazl58) are in the PS5 3.20 inventory and hash to those zlib names (#13745). Prototypes follow zlib.h 1.3.1;uncompressfollows the uncompr.c contract. Not measured on a console.z_streamis a 112-byte LP64 struct (GuestZStream, offsets asserted). It is not passed to host zlib directly: on WindowsuLongis 32-bit and the guestzalloc/zfreeuse the System V ABI. Each stream owns a hostz_stream. The gueststatefield points at it, and a back-pointer check returnsZ_STREAM_ERRORfor a copied or foreign stream, as zlib'sstrm->state->strm != strmcheck does.APS5_VABItrampolines. Nullzalloc/zfreeare replaced byAPS5_VABIdefault allocators, as zlib fills in its own, so the guest never receives a host-ABI function pointer.total_in/total_outstay 64-bit in the guest. Each call applies the host delta. zlib reads the low 32 bits oftotal_in(the gzip trailer), so the value is also synced into the host stream.stateis left alone, cleared or set exactly as zlib does. A rejected deflate parameter leaves it unchanged; a rejected inflate window clears it.deflateBoundusesdeflateBound_z, so 64-bit lengths don't truncate on Windows.uncompresshandles 64-bit lengths inuIntchunks. ItsZ_BUF_ERROR/Z_DATA_ERRORresults for a zero-length destination, a short destination and truncated input match system zlib.NO_GZIP, so a valid gzip or auto-detectwindowBitsthrows instead of returning a wrong error. InvalidwindowBitsvalues still returnZ_STREAM_ERROR.Overlap:
tools/pr_overlap.pyreports only #14212 (docs(debt): drops export totals and adds blank lines across debt files), which edits the samelibSceNKWebKitRequirements.mdparagraph where this PR changes 133/122 to 123/112 and moves zlib out of the pending names. It implements no functions; the conflict is textual, and whichever merges second can take the other's wording.Tested
Ubuntu 24.04, GCC 13.3. New test
guest_webkit_zlib(core/libs/tests/GuestWebKitZlib.cpp), built standalone withZlib.cpp, the vendored zlib sources,-fsanitize=address,undefined -fno-sanitize-recover=undefined: passes in 0.24 s with no leaks or UB reports. It covers:deflateBoundexact values (1013, 1151, saturation)uncompressedge cases, with expected values taken from system zlib 1.3 through ctypeswindowBitsthrowingThe full CMake build was not run locally (SDL's X11/audio dev packages are missing on this machine), so
guest_webkit_zlibhas not run under CTest or on Windows.python3 tools/check_conventions.py --base origin/main,core/libs/tests/test_public_headers.py --audit-onlyandtools/tests/test_progress.pypass. No title tested.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T10:56:00Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The guest zlib bridge can leave stale upper bits in
GuestZStream::adleron Windows when the hostuLongis 32-bit.What I ran
Reviewed open PR #14374 at head
d95df1c6474f2e4b5f0249622c36bf2dbb91b40a, based onmainate6f57307fa7f47165d7fc1bee945abdb2f6816e7. The no-build stack preview against currentmaine67cc818696fd6e6c58ac80adc6550c54aed68e8was clean. Environment: Linux x86_64, Python 3.11.2; no compiler was invoked.The test-quality and public-header commands ran from the exact-head snapshot at
/tmp/anyps5-14374-exact.Results
guest_webkit_zlibis registered in the changed CMake file. The test-quality helper's possible-unregistered warning is a false positive.e67cc818696fd6e6c58ac80adc6550c54aed68e8.Unedited selected command output
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14374:The precheck report shows its ABI and test-quality subprocesses could not run because those local helper files are absent from the isolated PR snapshot; I ran both available helpers directly afterward.
python3 tools/pr_abi_audit.py ... --jsonsummary:python3 tools/pr_test_quality.py ...:python3 core/libs/tests/test_public_headers.py --audit-only:git diff --check ...produced no output and exited 0.Findings
Blocking: In
Zlib.cpp,Store()comparesstream.adlerwithstatic_cast<uLong>(guest.adler)before deciding whether to write the result back. On Windows, where hostuLongis 32-bit, a guest value such as0x1_00000001truncates to1; zlib initialization resets the checksum to1, so the comparison treats the values as equal and leaves the stale upper 32 bits in the guest-visible 64-bit field. Please compare in guest width (or always store the host value), and add a regression that seeds the upper bits before initialization and checks the result on a 32-bit-uLonghost.Sources
deflateResetKeepchecksum initialization.Not verified
I did not compile or run C++ tests/CTest, test on Windows, or verify console behavior. The author reports a standalone Ubuntu ASan/UBSan run, but I did not independently reproduce it. Hosted checks were pending at the last query.
To get this to a good state
Normalize the guest-visible checksum after host operations and add the high-bit regression. I will rerun the same no-build checks on the new head; build-dependent tests remain outside the initial-review check set.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T11:49:26Z.
Review: COMMENTED
Re-checked — new head, Store fix confirmed
At
3979b705f3the guestadlercomparison is done at full 64-bit width, which resolves the stale-upper-bits problem in my earlier request atd95df1c647; approval waits for hosted Windows results at this head.What I ran
Exact head
3979b705f3b87d75827d036a587be8c37bc6f148, PR basee6f57307fa7f47165d7fc1bee945abdb2f6816e7. The no-build stack preview against currentmainwas clean. No build, compile or C++ test was run.The precheck's ABI and test-quality helpers could not run in its isolated head tree, so I ran both by hand from
/marc/AnyPS5, as shown above.Results
GuestWebKitZlib.cppnot found literally in CMake. False positive:core/libs/prx/libSceNKWebKitRequirements/CMakeLists.txt:9registers it asguest_webkit_zlib_teststhrough${LIBS_INCLUDE_DIR}/tests/GuestWebKitZlib.cppStore()Zlib.cpp:114now readsif (guest.adler != static_cast<std::uint64_t>(stream.adler)) guest.adler = stream.adler;.GuestZStream.hpp:27declaresstd::uint64_t adler, so the comparison is full width and a stale upper half is overwrittenFindings
Blocking: none.
Non-blocking: none new at this head.
Not verified
51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf) was not compared with upstream text here.3979b705f3.To get this to a good state
Nothing further is needed from the author for the source point. Approval waits for the hosted Windows results at
3979b705f3, and for the licence text to be confirmed against upstream.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T12:44:05Z.
Review: APPROVED
Reviewed — looks good
The zlib exports at
3979b705f3compare the adler checksum as a full 64-bit guest field, which fixes the earlier changes-requested finding, and the hosted Windows run for this exact head passed all 2586 CTest tests, includingguest_webkit_zlib; I approve.What I ran
Exact head
3979b705f3b87d75827d036a587be8c37bc6f148; PR basee6f57307fa7f47165d7fc1bee945abdb2f6816e7(precheck base), unchanged at completion. No local build and no local test run. Commands:The precheck's ABI and test-quality helpers were missing from the isolated head tree, so both were run by hand. I also compared the licence notice in
Zlib.cppline by line with zlib 1.3.1zlib.hat51b7f2abdade71cd9bb0e7a373ef2610ec6f9daf: all 10 licence lines match verbatim.Results
possible-unregistered-cpp-testfinding; false positive, becauseguest_webkit_zlibis registered incore/libs/prx/libSceNKWebKitRequirements/CMakeLists.txtL9-L10guest_webkit_zlibUnedited hosted log lines (Windows job)
Findings
Blocking: none.
Non-blocking:
What I read: the checksum compare in
Zlib.cpp(the guest field is compared at full 64-bit width and normalised when it differs), the 64-bitadlerfield inGuestZStream.hpp, and theuncompressadaptation of zlib 1.3.1uncompr.c, which the file header names.Sources
zlib.hlicence text at the pinned commitZlib.cppat the reviewed headNot verified
To get this to a good state
No change is needed for the approval.