feat(libSceNKWebKit): implement WTF release leak-counter no-ops and descriptor helpers #19103
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19103"
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 KernelPanicNT on 2026-11-12T19:43:13Z.
What
Implements nine
libSceNKWebKitWTF exports that threw throughNotImplemented_nid_no_patch.WTF::RefCountedLeakCounter(6 exports, empty bodies).C1(const char*)(7l4jBeWiHI4),C2(const char*)(opqf3CJzhms),increment()(FpxnD+vtdFQ),decrement()(rtWWBSqgRzo),suppressMessages(const char*)(+Abk7CfTivU) andcancelMessageSuppression(const char*)(SM0Cf+K17Yw) move tosrc/NoOpExports.cppas empty functions, next to theD1/D2destructors that are already there.These bodies follow the release (
NDEBUG) build of WebKitc55364d53f97. In that build every member ofRefCountedLeakCounteris empty and the struct has no fields. In a debug build the counter keeps an atomic count and a description, and the destructor logs leaks. Why the release build is assumed:RefCountedLeakCounterdestructors are bareretbodies. That is whyD1/D2are already empty insrc/NoOpExports.cpp(see the No-op exports entry indocs/dev/debt/libSceNKWebKit.md). A debug-build destructor readsm_countand can log, so it cannot compile to a bareret. Only the release build gives that body.String,StringBuilder,TextStream,URL) already follow the release build.The constructor,
increment,decrementand the two static functions were not read from a module themselves. The new debt entry says this.WTF::setNonBlock(int)(ZH232ViZnko),WTF::dupCloseOnExec(int)(wQ9-tXakN90) andWTF::sleep(Seconds)(gsFoqQ-R5js) are in a newsrc/WtfUniStd.cpp.fcntl_nid_postfix,dup_nid_postfixandclose_nid_postfix, with guest errno from__error_nid_postfix. This is howlibSceLibcInternal'sfdopendircallsfcntl, and libSceNKWebKit already links libkernel. Commands and flags use the FreeBSD numbers that the guest layer decodes:F_GETFD1,F_SETFD2,F_GETFL3,F_SETFL4,F_DUPFD_CLOEXEC17,FD_CLOEXEC1,O_NONBLOCK4 andEINTR4. These are not the host values.dupCloseOnExectakes the#ifdef F_DUPFD_CLOEXECpath of the source, because FreeBSD definesF_DUPFD_CLOEXEC. It retriesfcntl(fd, F_DUPFD_CLOEXEC, 0)onEINTR. If that fails for another reason, it falls back todupplussetCloseOnExec(F_GETFD/F_SETFD, also retried onEINTR). If setting the flag fails, it closes the duplicate with the non-LinuxcloseWithRetry, which retriescloseonEINTR, and returns -1. Today the guest layer answersF_DUPFD_CLOEXECwithEOPNOTSUPPfor files and sockets, so the fallback is the path that runs. If the guest layer starts supporting command 17, nothing changes here.setNonBlockreadsF_GETFLwithout checking it, then setsflags | O_NONBLOCKwithF_SETFL, retrying onEINTR. It returns whether that last call succeeded, as the source does.sleep(Seconds): WebKit waits on a privateConditionwithwaitFor, so the deadline isMonotonicTime::now() + value.waitUntiland theParkingLotloop only block whilenow < deadline. The port loops on the tree'sMonotonicTime::nowandstd::this_thread::sleep_for(in chunks of at most an hour). It returns at once for zero, negative,-infand NaN values, and it never returns for+inf.Debt: the eight rows leave the Additional callable exports table (
suppressMessageswas declared ininclude/Api.hppand had no row). The table's count is left as it is, since the debt file says inventory prose keeps historical counts. Two entries are added. The first says that the leak-counter bodies come from the assumed release build and were not checked against a module. The second says that the descriptor helpers andsleepcome from the pinned source, not from a device, and thatF_DUPFD_CLOEXECanswers as the guest layer models it.Source of the behaviour
c55364d53f97RefCountedLeakCountermembers#ifdef NDEBUG: every body empty, no fields; debug destructor logs leaksdupCloseOnExecF_DUPFD_CLOEXECwithEINTRretry, thendup+setCloseOnExec,closeWithRetryon failurefcntl/dup/closewith FreeBSD numberssetNonBlockF_GETFL, thenF_SETFLwithO_NONBLOCKretried onEINTRsleep(Seconds)Condition::waitForon a private lock untilnow + value!(now < deadline)NDEBUG)setCloseOnExec,dupCloseOnExec,setNonBlock), UniStdExtras.h#L37-L51 (closeWithRetry)sleep), Condition.h#L69-L89 and #L114-L117 (waitUntil,waitFor), ParkingLot.cpp#L594-L604 (wait loop)Tested
Linux x86-64 (Ubuntu 24.04, GCC 14), on
main09ab49de9649.nkwebkit_noopscalls the six leak-counter exports with a description, a null description, a reason and a null reason. It checks that the one-byte object is left alone and that no call reachesNotImplemented_nid_no_patch.nkwebkit_wtfgetsTestUniStdExtrasandTestSleepSeconds. On a guest file opened withsceKernelOpen:setNonBlocksetsO_NONBLOCK, keepsO_RDWRand is idempotent.dupCloseOnExecreturns a new descriptor withFD_CLOEXECset, and the original keepsFD_CLOEXECclear. The duplicate shares the file offset (write through the duplicate,lseekon the original). On a closed descriptorsetNonBlockreturns false with errnoEBADF, anddupCloseOnExec(-1)returns -1 withEBADF.sleep(0.05)waits at least 50 ms; zero, negative,-infand NaN return at once.ctest -R '^nkwebkit_(noops|wtf)$'passed in 2 of 2 runs.NotImplemented_nid_no_patch, both tests abort.tools/progress.py --compare: +9 implemented.tools/check_conventions.py --base origin/mainpasses.Not tested on a device or with a title.
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-13T18:41:29Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
c768ed1db0:tools/check_conventions.pypassed;git diff --checkclean.nkwebkit_noops_tests,nkwebkit_wtf_testsbuilt cleanly.nkwebkit_noops,nkwebkit_wtf):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/NoOpExports.hpp,core/libs/prx/libSceNKWebKit/include/WtfExports.hpp,core/libs/prx/libSceNKWebKit/src/NoOpExports.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me