fix(libSceNpCppWebApi): count Vector<String> and Vector<unsigned long> references where the bundled module does #10925
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10925"
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 AlexFigas on 2026-10-25T10:35:36Z.
What
libSceNpCppWebApicounted everyIntrusivePtr<Vector<T>>reference at offset 0x30 in the pointee, and its pointer/deleter constructor did not count the reference it adopts. The module bundled with PPSA21564 (sce_module/libSceNpCppWebApi.prx, the library's own code) puts the count 0x18 bytes past a first member the size of one element. That is 0x20 for 8-byte elements, 0x30 forIntrusivePtrelements and 0x38 forStringelements. EveryIntrusivePtr<Vector<T>>destructor, copy constructor and pointer/deleter constructor the module exports agrees.For
Vector<String>, the module's code does the following (addresses in the relinked module, read from the disassembly):Vector<String>::Vector(LibContext*)(0xabc0) zeroes the 32-bit count at 0x38.IntrusivePtr<Vector<String>>::IntrusivePtr(Vector<String>*, deleter, LibContext*)(0x10fc0) stores the three fields and increments the count at 0x38 when the pointer is not null. The copy constructor (0x11010) increments it too.lock xadd. When the old value was 1, it destroys the object through the deleter.pushBack(0xacf0) keepsbegin, the capacity end andendat 0x20, 0x28 and 0x30.For
IntrusivePtr<Vector<unsigned long>>, the destructor (0xe890, which jumps to 0xe7d0) and the assignment (0xe8a0) use 0x20.PPSA21564's own code creates a
Vector<String>withoperator new(0x48)and the exported constructor (0x2dbece to 0x2dbeec), so the count lives in title memory that only the constructor initializes. Here, the constructor left those bytes alone and the pointer/deleter constructor did not count the adoption. The first release therefore decremented whatever value was there: it either leaked the vector or called the deleter while references remained.Changes:
Vector<String>constructor zeroes the count at 0x38.IntrusivePtr<Vector<String>>pointer/deleter constructor increments the count, and its copy constructor and destructor use 0x38.IntrusivePtr<Vector<unsigned long>>destructor and assignment use 0x20. The assignment goes throughAssignIntrusivePtr, which skips it when both pointers hold the same object, as the module does (cmp qword ptr [rdi], r14; je). Without that, a sole owner assigned to itself ran the deleter and then copied from the cleared pointer, losing the object.Vector<String>test starts from the constructor's 0 and checks adoption, copy, release and a null adoption.Vector<unsigned long>assignment, and the shared assignment test also assigns a sole-owner pointer to itself: the object, count, deleter and context must be unchanged and the deleter must not run.IntrusivePtrandVectordebt entries give the offset for each element type.The
IntrusivePtr<Vector<IntrusivePtr<T>>>functions keep 0x30, which the module confirms. The host-side body thatpushBackcreates is unchanged.Tested
Ubuntu 24.04 (WSL2), GCC 13.3, Release build with
BUILD_TESTING=ON, headb21d67cbdc, which adds the self-assignment guard tob7ec1d9006, which mergesmaincc26ab4438into the previous head743b6e0b79(mainf1e340be4a), and3fdaafe5c3before it (mainda026c7065).mainnow defines the fiveIntrusivePtr<Vector<String>>andIntrusivePtr<Vector<unsigned long>>exports this PR changes in a new block near the end ofExport.cpp, so the merge resolves the conflict by applying this PR's offsets and the adoption count there:libSceNpCppWebApibuilds, with no warnings.ctest -R np_cpp_web_apipasses all 9 tests, 3 runs each:guest_np_cpp_web_api_intrusive_ptr,guest_np_cpp_web_api_string,guest_np_cpp_web_api_signed_outandguest_np_cpp_web_api_offline,main'sguest_np_cpp_web_api_matchmakingandguest_np_cpp_web_api_title_cloud_storage, and the alias testsguest_np_cpp_web_api_alias_append,guest_np_cpp_web_api_alias_string_vectorandguest_np_cpp_web_api_alias_intrusive_vector. WithExport.cppfrommaincc26ab4438,guest_np_cpp_web_api_intrusive_ptrandguest_np_cpp_web_api_stringabort.Export.cppfromb7ec1d9006(the assignment without the guard), the self-assignment case ofguest_np_cpp_web_api_intrusive_ptraborts.python3 core/libs/tests/test_public_headers.py --audit-onlyverifies 394 libraries and 25128 exports.python3 tools/check_conventions.py --base origin/mainpasses.python3 tools/pr_overlap.py --branch fix/npcppwebapi-vector-reference-countsreports:mainor with this head. It appended destructor rows at the end of the table inGuestNpCppWebApiIntrusivePtr.cpp, where this PR's two rows were, so65a8e8e55bmoved them next to theStringdestructor; this PR does not depend on it.Stringdebt entry between theIntrusivePtrandVectorentries this PR edits, so the two conflict indocs/dev/debt/libSceNpCppWebApi.md.Export.cppandGuestNpCppWebApiString.cppmerge cleanly, and with #12801 merged into #11221's head3760ab79c2, which contains this head, the 9np_cpp_web_apitests pass 3 runs each. #12801 declaresDepends on: #10925.Vectorentry this PR rewrites, so each conflicts with this PR indocs/dev/debt/libSceNpCppWebApi.mdonly. This PR was reviewed first, so both declareDepends on: #10925(#13255 also on #11221).StringVectorReferenceCountOffsetconstant next toVectorReferenceCountOffset, theIntrusivePtr<Vector<String>>release inExport.cpp, and rows ofGuestNpCppWebApiIntrusivePtr.cppand the debt file. Neither merges with this head without a conflict, though both merge withmain. This PR was opened and reviewed first; they declareDepends on: noneand#14122, #12447, so I have not added a dependency here and leave the order to be agreed there.main. It has no review yet and this PR does not wait for it.main()keep #9015's rows and calls next to this PR's.No title run.
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-10-25T11:06:44Z.
Review: APPROVED
Reviewed head
f4296894ac390b15c1ff7c75f2ec785a167a5b86. The String-vector constructor initializes the count before pointer adoption increments it; copies/destruction use 0x38, and the unsigned-long vector assignment/destructor use 0x20, matching the offsets and module evidence in the PR. The tests check the affected count slots and deleter behavior. Independently ran strict C++20 syntax checks for the changed implementation and test files, plus conventions andgit diff --check; all passed. I did not rerun the runtime suite locally; the author reports the four focused CTests pass. The disclosed same-object assignment behavior remains a separate follow-up.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T11:15:28Z.
Review: APPROVED
Reviewed exact head f429689. The String-vector and unsigned-long-vector reference offsets are separated and applied consistently to construction, copies, assignment, and destruction; the tests check reference changes and deleter behavior. Local strict syntax, conventions, and diff checks passed. The author reports four Linux runtime tests; I did not rerun them locally. The documented self-assignment limitation remains outside this change.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T11:07:47Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
Your update confirms the implementation was replayed unchanged and reports the focused WebApi and alias tests passing on head
6d00d394d7. The branch still incorporatesmainonly through1db077e876; currentmainis nowba5b5330b3. The current-main diff does not touch this PR's implementation or test files, but the contribution rule requires the PR to be based on current main. Please mergeba5b5330b3and rerun the listed focused tests on the resulting head. Preserve the declared #11631 landing order and the coordination with #12801 for the shared debt entry.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T11:42:34Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The reference-count fixes remain consistent with the earlier review, but the current head is behind
mainand does not include the current head of declared dependency #11631.What I ran
Reviewed head
5c847d9387cb636e36a2edafe6059f1d782122e3against PR base98ddd9c1792bbab016ceed5db267a93d1d61f00a. Currentmainis1c6b316cf762c7a8d34623907d62bc1cba2217b6. Environment: Debian 12 x86_64, Python 3.11.2, GCC 12.2.0. The current-main merge preview is clean; no local build or CTest run was performed.Results
mainis not an ancestor of this headmainObserved stack and CI output
Negative control
Not applicable to this recheck: no new behavior assertion was added since the earlier exact-head runtime test report.
Findings
Blocking
The branch includes
mainonly through98ddd9c1792bbab016ceed5db267a93d1d61f00a, while currentmainis1c6b316cf762c7a8d34623907d62bc1cba2217b6.CONTRIBUTING.mdrequires keeping branches up to date. The PR also declares dependency #11631, but its current head is absent and that PR currently conflicts withmain. The minimal next step is to resolve/rebase #11631, then refresh this branch on currentmainwith the updated dependency and rerun the focused tests on the resulting head.Non-blocking
The intervening
maincommits do not touch this PR's implementation or test paths, and the current-main merge preview is clean. The reported tests are useful evidence for the unchanged code but do not verify the refreshed dependency chain.Sources
Not verified
No local build or CTest run; author-reported focused tests only. No PS5 console/title behavior. The refreshed dependency stack has not been tested.
To get this to a good state
After #11631 is resolved on current
main, rebase this PR on its updated head and currentmain, then rerun the four focused tests plus the three alias tests three times. I will rerun the same no-build checks and review that exact head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T14:58:18Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The implementation and its reported focused tests remain consistent with the earlier review, but this branch still does not include current
main, as required by the repository rules.What I ran
Reviewed head
3fdaafe5c346ba6640cb2afd0045e8139ac50c9eagainst PR baseda026c70655a132031d45e2008c24f993870d801on Debian 12 x86_64, Python 3.11.2, GCC 12.2.0. Currentmainised1e0ed08fc2452192df91793a33dd0cc7ad5212; the merge preview is clean.Results
9b0c08ba14c5101ae02d5e3417b92a547999c852.Depends on: none; #11631 no longer overlaps the moved destructor rows. #11221 is stacked on this PR, and #12801/#12808/#13255 declare this PR as a dependency.np_cpp_web_apitests pass three runs on this head, with the two directly affected tests aborting againstmain's originalExport.cpp; the 374-library/23,571-export header audit passes. I did not run these locally.Selected unedited output
Negative control
The author reports that the two directly affected tests abort when run with the baseline
Export.cppfrommain. I did not independently run that control or build an exact-head binary.Findings
Blocking
The PR head contains
mainonly throughda026c70655a132031d45e2008c24f993870d801, while currentmainised1e0ed08fc2452192df91793a33dd0cc7ad5212.CONTRIBUTING.mdrequires keeping the branch up to date. The merge preview is clean and interveningmainchanges do not touch this PR's files, but the branch remains behind. Please merge currentmaininto this branch and rerun the focused tests on the resulting exact head.Non-blocking
The stack checker reports a self-cycle despite confirming the PR's checklist has no dependency and the merge preview is clean. Its ABI and test-quality helpers are also unavailable in the isolated checkout.
Sources
Not verified
No local build or CTest run; the focused tests and header audit are author-reported. No PS5 title run.
To get this to a good state
Merge current
maininto the branch and rerun the sevennp_cpp_web_apitests plus the header audit on the resulting exact head. I will repeat the no-build checks and review that head before responding again.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T01:11:29Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The implementation and reported tests remain consistent with the earlier review, but the open overlap with #14122 and #14136 has no agreed landing order and causes real merge conflicts.
What I ran
Reviewed head
b7ec1d9006b704cc84f98391ea566ee92844f68fagainst basecc26ab44380db3cd7b53715b84f13945227ce28bon Debian 12 x86_64, Python 3.11.2 and GCC 12.2.0. Its preview onto currentmain(7c4dcf0ad84de7a473ce97bb21644c614f1c3bd3) is clean. The #11221 dependent head1c163f759c3854e6c8b5c433d8bbbfcc566efd1bincludes this head.Results
fea8af4f74c18d3141995da878164d239c1b0533.Export.cpp,GuestNpCppWebApiIntrusivePtr.cpp, and the debt file.np_cpp_web_apitests pass three runs on this head, withintrusive_ptrandstringtests failing against baselinemain; I did not run them locally.Selected unedited merge-preview output
Findings
Blocking
The live overlap previews conflict with #14122 and #14136 in the implementation, intrusive-pointer tests, and debt file. The PR discussion says the landing order is still for the authors to agree, and the checklist remains
Depends on: none. The repository requires overlapping PR authors to agree on order and declare dependencies. Please coordinate the order with the authors of #14122 and #14136 and update the relevantDepends onlines before this stack is ready.Non-blocking
The head is behind current
main, but its current-main preview is clean andmainhas not changed these PR paths since the base; I am not requesting a rebase for age alone. Windows CI was still pending at this snapshot.Sources
Not verified
No local build or CTest run. Windows checks are pending; no Linux product run or console run. The reported test results are author-provided.
To get this to a good state
Agree with the owners of #14122 and #14136 which PRs land first, record the order in the affected checklists, then rerun the pairwise merge previews and current
mainpreview. I will repeat these checks on the updated heads.