Repository navigation
feat(libSceJxr): implement WMPAlloc, WMPFree and the memory stream - #14631
Conversation
|
Thanks. I compared these with jxrlib at the pinned commit ( One thing: this is ported code, so the project rule on ported code applies: code copied or ported from a permissively licensed project keeps that project's licence notice. Please add jxrlib's notice from the top of Reviewed at 03f2eb9. |
Progress report (03cfa4c → 1a28810)📈 System libraries: 26.73% (+0.02%, +8 implemented functions) ✅ 8 implemented
Changed libraries (implemented exports)
|
There was a problem hiding this comment.
Correction (2026-11-01): the title-ID/log demand below is not a CONTRIBUTING requirement; Unblocks: none is allowed. The technical points below are unaffected.
Unblocks is none and the body names no title that calls WMPAlloc/CreateWS_Memory on main. The comparison is against jxrlib's strcodec.c source, which shows the contract, not that a title reaches these eight exports. Please add the title ID and the log line (unresolved import or NotImplemented hit with the queue position) that ties this to a running title; otherwise it is the export-only pattern.
One code question: ReadWS_Memory returns success without copying when the position is past the end, and SetPosWS_Memory accepts any position with no bound, as jxrlib does. With state[MemoryPosition] guest-controlled through SetPos, buffer + position on the write path is only guarded by the MemorySize < position + size check, which holds. Is the null buffer with nonzero MemorySize throw (APS5_INVALID_ARG_EX) what jxrlib does, or a crash there? The body says it throws where jxrlib would dereference null; a guest that relies on that crash cannot exist, so fine, but please say whether any title was seen passing a null buffer.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings; the JXR memory stream is implemented, and its tests passed on Windows
This PR replaces the NotImplemented stubs for WMPAlloc, WMPFree and the memory-stream callbacks in libSceJxr with working code: a calloc-backed allocation, and a memory stream with bounded read, write, seek and end-of-stream logic. The Windows CTest run passed the JXR lookup cases and guest_jxr_stream. I read the production change in full. I did not read the test bodies in JxrStream.cpp.
What I ran
- Head
03f2eb905b61663f3ddc1ca9e7001eb7b3cae9b5; basef2d874c1fdccf781c0fa5d86619bb5dd8894b958. 4 files, +224/-25:libSceJxr/Export.cpp(+84/-25),libSceJxr/include/Api.hpp(+16/-8),core/libs/tests/JxrStream.cpp(+145), and a debt line. - Read the
Export.cppandApi.hppdiffs in full. The memory stream keeps buffer, size and position instate. Reads and writes check for overflow and clamp to the buffer size, and anendcheck reports end of stream.CloseWS_Memoryfrees the stream throughWMPFree. - Test source: read the test names only, through the CTest output.
- Hosted, Windows CTest: 2594 of 2594 passed.
guest_jxr_lookup_reference,guest_jxr_lookup, its patched and padding variants (Test #2274 to #2280),guest_jxr(Test #2281) andguest_jxr_stream(Test #2282) all passed. - Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed (no declared dependencies, no errors). ABI audit passed: 137 symbols.
- The test-quality helper flagged
JxrStream.cppas possibly unregistered. Not investigated further. - No MarcZX10 review at this head.
Results
| Check | Result | Note |
|---|---|---|
| Diff check | passed | |
| Conventions and PR template | passed | conventions check from the main checkout |
| Mergeability and dependencies | passed | stack check: no declared dependencies, no errors |
| ABI audit (main-checkout tool) | passed | 137 symbols |
JXR lookup cases and guest_jxr_stream (hosted, Windows) |
passed | Test #2274 to #2282 |
| Memory-stream logic (read) | passed by reading | overflow checks and clamping are present; no blocking defect found |
| Signatures against the PS5 headers | not verified | the return types were changed from int to std::int64_t in this PR; not compared with PS5 |
Test bodies in JxrStream.cpp |
not verified | names only |
| Relinkers (hosted) | skipped | not run for this change |
| Negative controls | not run | no local build |
Read-only check output
Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: passed (137 symbols). Stack check: passed, no errors. Hosted: gh api repos/boykopovar/AnyPS5/commits/03f2eb905b61663f3ddc1ca9e7001eb7b3cae9b5/check-runs, and the Windows job log.
Negative control
Not run here. A negative control needs a local build and run of the JXR tests, and code from this head is not run here.
Findings
Blocking
None from the code read.
Non-blocking
- The exported return types moved from
inttostd::int64_t(andEOSWS_Memorytostd::int32_t). These are this PR's choices. They were not compared with the PS5 signatures in this pass.
Sources
- Implementation: https://github.com/boykopovar/AnyPS5/blob/03f2eb905b61663f3ddc1ca9e7001eb7b3cae9b5/core/libs/prx/libSceJxr/Export.cpp
- Header: https://github.com/boykopovar/AnyPS5/blob/03f2eb905b61663f3ddc1ca9e7001eb7b3cae9b5/core/libs/prx/libSceJxr/include/Api.hpp
- Test: https://github.com/boykopovar/AnyPS5/blob/03f2eb905b61663f3ddc1ca9e7001eb7b3cae9b5/core/libs/tests/JxrStream.cpp
- Windows job log: check-run
windowson 03f2eb9
Not verified
- The bodies of the tests in
JxrStream.cpp. - The signatures against the PS5 headers.
- The Linux build and runtime tests (not run).
To get this to a good state
- Nothing blocking. Check the signatures against the PS5 headers if they are available.
✅ AMD GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (4, not counted against this PR)Validation IDs already present on main (4 IDs in 487 tests)Skipped (9)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
The WMPAlloc, WMPFree and memory stream ports, like PKFree, readIS and writeIS, follow jxrlib's strcodec.c; the notice is lines 1-27 of that file at f7521879862b9085318e814c6157490dd9dbbdb4.
|
Hi @ahmadmuj, thanks for the WMPAlloc, WMPFree and memory stream work. We merged main into your branch (the only conflict was the export count in the technical debt file, now 123) and added jxrlib's licence notice, lines 1-27 of |
|
On the remaining null-buffer question: jxrlib accepts null during construction, then passes it to
|
What
Implements the jxrlib allocator pair and the memory stream in libSceJxr:
WMPAlloc,WMPFree,CreateWS_Memory,EOSWS_Memory,ReadWS_Memory,WriteWS_Memory,SetPosWS_MemoryandGetPosWS_Memory.They follow the pinned jxrlib strcodec.c line by line:
WMPAllocis guestcalloc(1, cb), -101 on failure;WMPFreefrees a non-null*ppvand clears it.CreateWS_Memoryallocates the 88-byteWMPStream(the existingJxr::Stream) and stores buffer, size, position 0 and the six callbacks.Closeis jxrlib'sCloseWS_Memory, which isn't in the export inventory, so it's a private_nid_no_patchhelper.cbCur + cbwraps, otherwise clamps and copies. Write returns -103 on wrap or past the end and leaves the position alone. SetPos has no bounds check, same as jxrlib.ppv, stream,poffPos, a buffer when at least one byte is copied) it throwsstd::invalid_argument, like readIS does. The well-defined null cases (past-end read, zero-byte copy, nullpvin create) return normally.This is the first way to create a stream for the merged readIS/writeIS. Debt entry added, and the "additional exports" count goes from 132 to 124.
Tested
Ubuntu 24.04 on WSL2, GCC 13.3, Release build.
ctest -R guest_jxr: 9/9 pass. New cases inJxrStream.cpp: allocation (zeroed, -101 onSIZE_MAX, free clears), create state and callbacks, read clamp / at-end / past-end / wrap, write overflow / wrap / zero-byte cases, EOS and positions, close through the stored callback, and readIS/writeIS driving a memory stream (full packet, clamped last packet, overflowing write returning -103 without advancing).libSceJxr.prxaborts withWMPAlloc_nid_postfix not implemented.SIZE_MAX, positions past the end. Return values, stream state,fMem, GetPos output and buffer bytes all match (2.46M checks, 0 mismatches). WMPAlloc/WMPFree also match for sizes 0 toSIZE_MAX.public_headerspasses;python3 tools/check_conventions.py --base origin/mainpasses.Not tested: console behaviour (no PS5 or dumps), Windows. No title is known to call these yet.
Overlap:
tools/pr_overlap.py --branch(1833 open PRs) flags only #14425 (PKAlloc), on the debt file's export-count line: both PRs lower the 132. No shared export or test case. Whichever lands second fixes that one number.gh search prsfinds no other PR on these names.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)