feat(libSceNpUniversalDataSystem): implement the Int record builders #14912
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14912"
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 edubox on 2026-11-02T00:47:30Z.
What
The
libSceNpUniversalDataSystemInt record API threwnot implemented. This implements the record builders whose signatures and checks are visible in the 11.00 module wrappers:IntInitialize,IntTerminate,IntDeleteAllRecord,IntGetMemoryStat.IntCreateRecordArray/IntCreateRecordObject/IntCreateRecordData, their three destroy functions, andIntRecordDataEstimateSize.IntRecordArraySet*setters and the elevenIntRecordObjectSet*setters.The host models record arrays and objects with the event property array and object types: arrays append typed values, objects set string keys, nested objects and arrays are cloned, and the stored copy is returned through
value_ptr.IntCreateRecordDatarecords the validated type inrecordTypeand an emptycontextobject. A returned child stays usable while its owner is alive and is invalidated when the owner is destroyed. Lifecycle and record operations share one lock, andIntInitializeuses a compare-exchange.The wrappers at
0x1410(array),0x1c00/0x3050(data/object),0x1540–0x18f0(array setters),0x3190–0x3600(object setters),0xf40/0xfb0(initialize/terminate),0x1000(memory stat),0x2fa0(estimate) and0x13f0(delete all) establish the signatures and the confirmed error codes0x80553101,0x80553102,0x8055310D,0x80553114,0x80553115,0x80553119and0x8055311A.IntInitializerequires a 16-byte{size, memory}parameter. The console's record store, serialization and estimate are not measured: the 11.00 module calls itsSceNpUdsimports for the allocator and size contract, soIntGetMemoryStatandIntRecordDataEstimateSizethrow after their argument checks instead of inventing output values. The memory pool passed toIntInitializeis ignored.IntPostRecordData, the streams, the context/handle Int exports andIntGetObjectStatestill throw.Tested
BUILD_TESTING=ON: builtguest_np_uds_records_tests;ctest -R '^guest_np_uds_records$'passes.IntDeleteAllRecord/IntTerminate.np_uds_events,guest_np_uds_queriesandguest_np_trophy_*tests still pass.python3 tools/check_conventions.py --base origin/main: all checks pass.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T10:05:56Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The current implementation still rejects its returned nested children, is unsafe against concurrent lifecycle operations, and implements success semantics that the PR itself says are unmeasured.
What I ran
Reviewed head
5b9869d185c7523bef3b4dd048b2b30c01ff381eagainst base93dbd0f82aea684e95f15f06e7d42c0064af18cf. The PR is open and the head was unchanged at final refresh. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5. I did not configure, build, or run C++ tests locally.Results
Precheck summary and test evidence
The precheck reported
diff_check: passed,conventions_and_pr_template: passed, andlive_dependency_and_mergeability_check: passed. Its ABI and test-quality helper invocations could not execute because those scripts are absent from the isolated PR snapshot. The standalone ABI audit passed with 93 symbols and no findings. The test-quality heuristic did not establish registration; manual CMake inspection confirmsGuestNpUniversalDataSystemRecords.cppis registered asguest_np_uds_records.GitHub checks at this head:
eligibility,conventions,library-portability,intake,labels,report, andwindowssucceeded;relinker,relinker-asan,register-context,write-watch, andlinuxwere skipped. The PR description reports a Linux GCC 14 Release build and focused CTest pass; I did not independently reproduce that result.Negative control
Not run: no C++ binary was built, so I could not remove any new behavior and demonstrate that the corresponding test fails. The new tests also do not exercise the nested-child mutation, lifecycle-contention, or destruction-race cases described below.
Findings
Blocking
Returned nested values cannot be used as records. The setters clone nested objects/arrays and return
child.get()throughvaluePtr(for example,Record.cpp:331-356). ButFindObjectandFindArrayaccept only pointers registered as roots ing_objects/g_arrays(:30-37); these children are owned only by the parent property and are never registered. Passing a successfulvaluePtrto a subsequent object/array setter therefore returnskNullObject/kNullArray. The tests only assert that the pointers are non-null (GuestNpUniversalDataSystemRecords.cpp:91-94, 116-120). Make returned children usable for their documented lifetime, define invalidation when an owner is destroyed, and test mutation through each returned type plus clone independence.Lifecycle and record operations can race into invalid memory.
IntInitializeperforms a separate atomicload()andstore(true)(Record.cpp:48-54), so concurrent initializers can both pass the already-initialized check. More seriously, setters callOwned::Contains, which releases its mutex before returning a raw pointer (NpUniversalDataSystem.hpp:39-50);DestroyRecord*,DeleteAllRecord, orTerminatecan then free that object while the setter uses it. Concurrent setters also mutate the same event-property vector/map without synchronization. Serialize initialization and make record ownership/lifetime cover each operation through its final access, or otherwise establish and enforce a documented single-thread contract. Add contention and operation-versus-destruction tests.Successful record behavior is explicitly unverified. The PR's debt entry says the host ignores the supplied memory pool, reports all memory statistics as zero, models Int records with event property types, and uses event MessagePack size for
IntRecordDataEstimateSize, while also stating that console record storage, serialization, and estimate behavior are not measured (docs/dev/debt/libSceNpUniversalDataSystem.md:16). The tests assert these chosen host semantics, but do not establish that they match the console contract. Provide implementation-source or hardware evidence for the successful representation, memory statistics, and size results; keep the affected success paths unimplemented until those results are supported.Non-blocking
None identified.
Sources
Not verified
To get this to a good state
Make returned nested children usable and lifetime-safe, serialize lifecycle and record access or demonstrate/enforce a single-thread contract, and provide evidence for the successful data/stat/size semantics or leave those paths unimplemented. Add regressions for each addressed case. On the new head I will repeat the no-build checks and inspect the updated tests; build-dependent results should be confirmed by CI or a focused build.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T09:40:31Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The Int record builders build,
guest_np_uds_recordspasses, and a targeted negative control fails as it should. One debt entry is now stale:docs/dev/debt/libSceNpUniversalDataSystem.mdstill saysIntInitializeandIntTerminateare parameterless stubs inExport.cppthat throw. They aren't anymore, and the project rules require that entry to be cut.What I ran
Head
2382ec90b4f3fa31816d15d1cdb4cda5f76cc3f3, merged with--no-ffintomain4f41f4c375f5abb487dbd184fbc150f31994d762(merged tree5d19f1d3cada7a43b52102701c610d6efcb16f8e). Debian 13 VM, GCC 14.2.0, Release, Ninja,BUILD_TESTING=ON.Results
git diff --checkcheck_conventions.pydebt-length, 1386 characters, line 34)guest_interfaces,guest_socket_options_multicast,unwrap_self_…,vector_constant_factor_tininess) and theguest_net_ctlskip also happen onmainand are not caused by this PRguest_np_uds_recordsguest_np_uds_queries,np_uds_events,guest_np_trophy_*(6 tests)guest_np_uds_recordsaborts atset on array childgit status --porcelainempty; test passes againcheck_conventions.py
Negative control
main,Record.cppkept: the build fails as expected (Ownedhas noForEach, andNpUniversalDataSystemIntInitParamis unknown). The new test uses the newApi.hppsignatures, so a full revert can't produce a test binary. This control shows only that the test depends on the change.FindObject/FindArrayaccept only registered roots (root == object, with no nested search), which is how the code behaved before the first review was answered. The test aborts withNpUniversalDataSystem records: set on array child. So it does cover the fix for returned nested children.Record.cppand rebuilt. The test passes and the worktree is clean.I did not mutate the locking. The race tests are probabilistic, so a negative control for them would not be conclusive either way.
Findings
On the first review's three blocking points, at this head:
g_recordsMutex, andIntInitializeuses a compare-exchange. Confirmed by reading the code.IntGetMemoryStatandIntRecordDataEstimateSizenow throw after their argument checks (NotImplemented_nid_no_patchis[[noreturn]], so there is no missing-return problem).Blocking
IntInitialize/IntTerminateis still there.docs/dev/debt/libSceNpUniversalDataSystem.md:30still listssceNpUniversalDataSystemIntInitializeandsceNpUniversalDataSystemIntTerminateas linked toExport.cpp, "declared without parameters" and throwing "until its signature is verified".Export.cpp, givesIntInitializea{size, memory}parameter insrc/Record.cpp, and implements both.IntDestroyContext,IntDestroyHandleandIntNetSyncTitles. The new Record builders entry already covers the rest.Non-blocking
MessagePackSizeoverloads are never called.src/UdsEvent.cpp:278-286and their declarations ininclude/UdsEvent.hpp:68-69were added for the size estimate. SinceIntRecordDataEstimateSizenow throws, nothing incore/calls them. Suggest removing them until a measured size contract needs them.src/Record.cpp:21-23returns0x80553116(null record),0x80553117(not initialized) and0x80553118(already initialized).0x80553101/02/0D/12/14/15/19/1Aas confirmed by the 11.00 wrappers.IntInitializechecks already-initialized before validating its parameter), which I could not check against the disassembly.docs/dev/debt/libSceNpUniversalDataSystem.md:34is 1386 characters and triggers thedebt-lengthwarning. Most of it describes implemented behaviour: the lock, the compare-exchange, the cloning. Cutting it to the gaps would fit the rule:IntDestroyRecordDataandIntDestroyRecordObjectare interchangeable. Atsrc/Record.cpp:212,IntDestroyRecordDatajust forwards toIntDestroyRecordObject. Each one therefore frees records created by the other's Create function. Whether the console separates them is unknown; this could be one more line among the unverified points in the debt entry.Not verified
7cf5a1a7ec).To get this to a good state
Remove
sceNpUniversalDataSystemIntInitializeandsceNpUniversalDataSystemIntTerminatefrom the Export.cpp debt entry at line 30. Preferably also drop the unusedMessagePackSizeoverloads and cut the Record builders entry to the open gaps.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T11:05:33Z.
Review: APPROVED
Re-checked — approved
The only new commit,
c8d28e6(docs only), resolves the one blocking finding. It removesIntInitialize/IntTerminatefrom the staleExport.cppdebt entry and cuts the Record builders entry down to its open gaps, which also covers two of my non-blocking points.What changed since my last review
c8d28e6722667cb0290e02ad268a0eb51769e272. It changes onlydocs/dev/debt/libSceNpUniversalDataSystem.md. Commits 1–3 are unchanged (range-diffshows=).IntDestroyContext,IntDestroyHandleandIntNetSyncTitles.0x80553116/0x80553117/0x80553118and the check order are unverified;IntDestroyRecordDataforwards toIntDestroyRecordObject.What I ran
Head
c8d28e6722667cb0290e02ad268a0eb51769e272, merged with--no-ffintomain4f41f4c375f5abb487dbd184fbc150f31994d762(merged treef6648dc0cc9b2127e57575dd9e3add7fd4320d1c). Debian 13 VM, GCC 14.2.0, Release, Ninja,BUILD_TESTING=ON.git diff --checkcheck_conventions.pyAll conventions checks passed., exit 0. Thedebt-lengthwarning from last time is gone.guest_interfaces,guest_socket_options_multicast,unwrap_self_…,vector_constant_factor_tininess) and theguest_net_ctlskip also happen onmainand are not caused by this PR.guest_np_uds_records,guest_np_uds_queries,np_uds_events, 5×guest_np_trophy_*)git status --porcelainemptyPrevious findings
IntInitialize/IntTerminatedebt entry: Resolved.docs/dev/debt/libSceNpUniversalDataSystem.md:30now lists onlyIntDestroyContext,IntDestroyHandleandIntNetSyncTitles. A grep finds neitherIntInitializenorIntTerminateinExport.cpporPendingExports.cpp.MessagePackSizeoverloads: Still open. The object and array overloads atsrc/UdsEvent.cpp:278-286and their declarations atinclude/UdsEvent.hpp:68-69have no callers. Only the event overload is used, atcore/libs/prx/libSceNpUniversalDataSystem/src/Event.cpp:89. This doesn't block the merge; removing them would be a small cleanup.0x80553116,0x80553117,0x80553118and the check order as unverified.check_conventions.pyno longer warns.IntDestroyRecordData/IntDestroyRecordObjectinterchangeable: Resolved as a documentation item. The entry now records that either one frees records created by the other.New findings
Blocking
None.
Non-blocking
None.
Not verified
7cf5a1a7ec. The new commit changes only documentation.