feat(libSceNKWebKit): implement 35 constructors that install a vtable rebuilt from the module #23482
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23482"
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 RiverWhy on 2026-11-19T04:22:27Z.
What
Implements 35
libSceNKWebKitconstructors and copy constructors whose module body only installs the class vtable and stores constant field values. One of them also copies one field. All 35 throwNotImplementedonmaintoday.Source: the
libSceNKWebKit.sprxwith SHA-2563af992253665387feeb5df90ff27dff683e3aa270cc4d92a0535b46ab18fa20d(the module the existing Constant-return exports debt entry reads as 11.00). For each constructor I read the body, followed itsleato the class vtable and rebuilt the vtable slot by slot from the module's relocations:__cxa_pure_virtual): points to__cxa_pure_virtual_nid_postfix, as #22682 does.ret,xor eax,eax; retormov rax,rdi; mov qword [rdi],0; ret: points to one of four local helpers with the same behaviour.Offset-to-top and type info are 0, as in the module (it is built without RTTI). The vtables are emitted as assembly
.quadtables, the wayForwardExports.cppemits its tail jumps, so slots can point at exports whose AnyPS5 placeholder declarations have other types.JSC::WeakHandleOwnerJSC::TypedArrayControllerWTF::FunctionDispatcherWebCore::MIMETypeCacheWebCore::XPathNSResolverWebCore::BlobRegistryImplWebCore::VisitedLinkStoreWebCore::FrameLoaderClientWebCore::LibWebRTCProviderWebCore::PluginInfoProviderWebCore::UserContentProviderWebCore::EmptyFrameLoaderClientWebCore::StorageNamespaceProviderWebCore::ContentSecurityPolicyClientWebCore::InspectorFrontendClientLocal::SettingsInspector::RemoteInspector::ClientInspector::RemoteControllableTargetThe constructors themselves are generated from their decoded bodies: the vtable store,
movl $1reference counts,movb $0/movq $0member clears and 16-bytevmovupsclears.RemoteControllableTarget's copy constructor also copies the 32-bit field at 8 from the source. The generator refuses any instruction outside that set. A null object (and, for that copy, a null source) throws.Left out, because at least one vtable slot points at module code AnyPS5 doesn't have (an allocation, a call into an internal function, and so on):
LoaderStrategy,MediaStrategy,SocketProvider,PageConsoleClient,ResourceHandleClient,HeapCellType, the two filter operations,InspectorTarget,RemoteAutomationTargetandRemoteInspectionTarget.DisplayRefreshMonitor's destructor calls an internal function and is also left out.Debt: the fragment
docs/dev/debt/changes/feat-nkwebkit-vtable-constructors.mdadds the Functional entry and removes the 28 inventory rows.Overlap: I fetched every open PR head and diffed it against
main. None removes these stubs, andmainhas no vtable for any of these classes. #22682 covers different interface bases.Tested
Linux Mint 22.3, GCC 13.3, Release:
nkwebkit_vtableconstructorstest runs every constructor on a 4 KiB object filled with 0xa5. It checks that the vptr is the class table's address point, that every decoded store landed (value, width, offset, the copied field) and that all other bytes are untouched. It checks that null objects throw, checks the four helpers, and checks per table the number of pure-virtual and helper slots and the zero header.libSceNKWebKit.prxthrough the test binary, reads every table through its accessor and names each slot withinfo symbol(demangling off). All 344 slots name exactly the function the module's relocation points at, or the helper standing in for an internal body.nkwebkit_*tests pass.tools/check_conventions.pypasses..quadreferences to__cxa_pure_virtual_nid_postfixinlibc.prx, which relies on MinGW auto-import of a data reference to another DLL. The Windows CI build will show whether that holds.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 PrivacyOnion on 2026-11-19T04:36:17Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
0977d4e483:tools/check_conventions.pypassed.nkwebkit_vtableconstructors_testsbuilt cleanly.nkwebkit_vtableconstructors):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/Api.hpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp,core/libs/prx/libSceNKWebKit/src/VtableConstructors.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass._ZN9Inspector24RemoteControllableTargetC2ERKS0_(void* self, const void* other),otheris unchecked when passed, but line 324 checksif (!other) throw std::invalid_argument(...)immediately after storing the vtable. Ifother == nullptr, passingstatic_cast<const char*>(other) + 0x8tostd::memcpyon line 325 causes undefined behavior, and the check on line 324 should precede any copying, but more critically, dereferencing or pointer arithmetic on nullptr or passing null to memcpy is undefined behavior. Furthermore, line 320 executes(void)other;indicating inconsistent handling before checking it.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T15:24:42Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
ad5f176872:tools/check_conventions.pypassed.nkwebkit_vtableconstructors_testsbuilt cleanly.nkwebkit_vtableconstructors):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/Api.hpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp,core/libs/prx/libSceNKWebKit/src/VtableConstructors.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T19:07:11Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
6407a6eef1:tools/check_conventions.pypassed.nkwebkit_vtableconstructors_testsbuilt cleanly.nkwebkit_vtableconstructors):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/Api.hpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp,core/libs/prx/libSceNKWebKit/src/VtableConstructors.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass._ZN9Inspector24RemoteControllableTargetC2ERKS0_checksotherprior to vtable assignment and memcpy.__cxa_pure_virtual_nid_postfixand reimplemented exports.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:54:56Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change based on the code inspected; the description reports successful Linux tests, while Windows linking remains unverified.
What I ran
Reviewed head
6407a6eef1f8a32dcbae48067266db810b4a10fc. No commands or tests were run;repo_read.pywas used to inspect the prepared diff and targeted repository files. The author reports 146/146 NKWebKit tests and convention checks passed on Linux Mint 22.3 with GCC 13.3; these results were not independently verified.Results
Findings
Blocking
None in the code inspected.
Non-blocking
None.
Not verified
Reviewed
VtableConstructors.cpp,VtableConstructorExports.hpp,tests/VtableConstructors.cpp,CMakeLists.txt,libSceNKWebKit.hpp, and the debt change note, along withdescription.md,commits.md,manifest.json, anddiff.patch.Export.cppandInventoryExports.hppwere excluded from the review bundle because they were too large; the other changed files were included, but their full text was not read. In particular, I did not inspect all ofLegacyExports.hpp,Api.hpp, or the added source/test files line by line. The module relocations, independent slot-by-slot comparison, reported test runs, Windows behavior, and actual build output were not independently verified.To get this to a good state
Nothing is required.
Pull request closed