You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(libSceNKWebKit): implement the WebCore::MessagePortChannel processForPort and hasAnyMessagesPendingOrInFlight exports - #24019
Implements 2 libSceNKWebKit exports of WebCore::MessagePortChannel. Both throw NotImplemented on main today.
processForPort(const MessagePortIdentifier&): returns the process entangled with the given port (m_processes[0] when the port equals m_ports[0], otherwise m_processes[1]). The std::optional<ProcessIdentifier> comes back in registers: the value in rax, the engaged byte in dl.
hasAnyMessagesPendingOrInFlight() const: true when m_messageBatchesInFlight is non-zero or either pending message vector is non-empty.
Source: the libSceNKWebKit.sprx with SHA-256 3af992253665387feeb5df90ff27dff683e3aa270cc4d92a0535b46ab18fa20d. The logic follows the pinned WebKit MessagePortChannel.cpp (licence notice kept). The object offsets come from the module's own code and match the pinned MessagePortChannel.h: ports at 0x8 and 0x18 (16 bytes each), process slots at 0x30 and 0x40 (value plus engaged byte), pending message vector sizes at 0x6c and 0x7c, batches in flight at 0xa0. They live in the new src/MessagePortChannelAbi.hpp.
Only the fields the two functions read were checked against the module; the other members are laid out from the pinned header.
Debt: the fragment docs/dev/debt/changes/feat-nkwebkit-message-port-channel.md adds the Functional entry and removes the hasAnyMessagesPendingOrInFlight inventory row (processForPort had no inventory row).
Overlap: no open PR matches MessagePortChannel, and on current origin/main both are still only the NotImplemented stubs.
How it was checked
Offline, against the module's own code (none of it is in the repository): both function bodies were disassembled and their byte blobs run against this implementation in a harness.
5,000,000 random channel objects (random bytes everywhere, ports equal to the first, the second or neither, near-misses differing in one word, random pending sizes and in-flight counts), 0 mismatches for both functions, comparing the returned value and engaged byte.
Four mutants (ignoring the object identifier, ignoring the second vector, ignoring batches in flight, swapping the slots) give 23561, 22908, 29218 and 200000 mismatches per 200000 runs, so the harness does tell the behaviours apart.
In the repository, the new nkwebkit_messageportchannel test builds channel objects in memory and checks both exports, including a port matching in only one of its two words, an unengaged process slot, vector capacity without size, and the field offsets.
Tested
Linux Mint 22.3, GCC 13.3, Release:
nkwebkit_messageportchannel passes (100% of the 1 test selected).
git merge-tree against current origin/main is clean.
Not run on Windows.
Checklist
Based on current main; no other open PR implements the same functions
One topic per PR; follow-ups go in a new PR
No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
No notes, investigation .md files or images added to the repository (attach them to this PR)
New third-party code is a submodule built from source
Generic behaviour, not specific to one title
Depends on: none
Fixes: none
Unblocks: none
GPUs tested: n/a
AI-assisted: yes
Summary by CodeRabbit
New Features
Message-port handling can now identify the process associated with a port and report whether messages are pending or in flight. These updates provide clearer visibility into message-port activity and support more accurate coordination between processes.
Tests
Added checks for process identification and message activity across idle, pending, and in-flight scenarios.
The reason will be displayed to describe this comment to others. Learn more.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against ba7902e762:
Conventions: tools/check_conventions.py failed.
(pull request): error: [pr-template] Fill in the pull request template: answer AI-assisted with yes or no
(pull request): error: [pr-template] Fill in the pull request template: fill Depends on with #N or none
2 findings, 2 errors; GitHub shows at most 10 error annotations, the job summary lists all
Build: nkwebkit_messageportchannel_tests built cleanly.
CTest (nkwebkit_messageportchannel):
1/1 Test #4718: nkwebkit_messageportchannel ...... Passed 0.02 sec
100% tests passed, 0 tests failed out of 1
The reason will be displayed to describe this comment to others. Learn more.
Reviewed — no blocking findings
The implementation follows the described field checks and includes focused tests; I did not run the reported checks, and two changed files were excluded from the review folder.
What I ran
Reviewed head ba7902e762955bf591da8bcb10fa4ffdae457320 using the prepared diff and pinned repository reader. No build or test commands were run.
Results
Check
Result
Note
Source review
passed
Core implementation and focused tests read
Reported checks
not run
Reported by the author
Full changed-file review
not run
Two files excluded from folder
Findings
Blocking
None identified in the files read.
Non-blocking
None.
Not verified
core/libs/prx/libSceNKWebKit/Export.cpp and core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp were excluded from the prepared review folder and were not read. The author reports that nkwebkit_messageportchannel, tools/check_conventions.py, and core/libs/tests/test_public_headers.py --audit-only passed on Linux Mint 22.3 with GCC 13.3; these results were not independently verified. Windows behavior was not run.
Files read: review/description.md, review/commits.md, review/manifest.json, review/diff.patch, core/libs/prx/libSceNKWebKit/include/MessagePortChannelExports.hpp, core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp, core/libs/prx/libSceNKWebKit/src/MessagePortChannel.cpp, core/libs/prx/libSceNKWebKit/src/MessagePortChannelAbi.hpp, core/libs/prx/libSceNKWebKit/tests/MessagePortChannel.cpp, and docs/dev/debt/changes/feat-nkwebkit-message-port-channel.md. Excluded changed files: core/libs/prx/libSceNKWebKit/Export.cpp and core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp.
Tested ba7902e762 merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.
Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 2 tests failed out of 6450; 99% tests passed, 2 tests failed out of 6450. 2 of the failing tests fail on main too. run
Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 6450; 100% tests passed, 0 tests failed out of 6450. run
AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
The reason will be displayed to describe this comment to others. Learn more.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 86601da188:
Conventions: tools/check_conventions.py passed.
Build: nkwebkit_messageportchannel_tests built cleanly.
CTest (nkwebkit_messageportchannel):
1/1 Test #4757: nkwebkit_messageportchannel ...... Passed 0.04 sec
100% tests passed, 0 tests failed out of 1
Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, 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/MessagePortChannel.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
Code reading:
Verified C++ calling convention and ABI for WebCore::MessagePortChannel::processForPort and hasAnyMessagesPendingOrInFlight, including pass-by-reference and optional return type representation in rax/rdx (engaged flag in dl) matching OptionalProcessIdentifier
Audited MessagePortChannelAbi.hpp struct layout, offsets, and field alignment against the WebKit upstream definitions and module offsets verified with static_asserts (ports at 0x8/0x18, processes at 0x30/0x40, pendingMessages size at 0x6c/0x7c, messageBatchesInFlight at 0xa0)
Checked AGENTS.md rules regarding license notices, lack of extraneous comments, debt fragment formatting, and removal of replaced stubs from Export.cpp, InventoryExports.hpp, and LegacyExports.hpp
Evaluated pointer handling, const-correctness, 64-bit integer comparisons, and LP64/LLP64 data type safety in MessagePortChannel.cpp and MessagePortChannelAbi.hpp
Inspected test coverage in tests/MessagePortChannel.cpp ensuring proper validation of port matching logic, fallbacks, empty vs in-flight/pending batches, and offset invariants
The reason will be displayed to describe this comment to others. Learn more.
Reviewed — looks good
The reviewed changes at head 86601da18889c31d23db6f00adcecdf074fc1e94 have no verified blocking defects; the implementation and its targeted tests support merging.
What I ran
Read the prepared diff and relevant changed source at the pinned head. No commands or tests were run. The description reports Linux Mint/GCC test and convention checks; those results were not independently run here.
Results
Check
Result
Note
Diff and source review
passed
Core behavior and test read
Automated checks
not run
Author-reported results only
Complete changed-file review
not run
Two large files partly unread
Findings
Blocking
None found in the read code.
Non-blocking
None.
Not verified
Export.cpp and include/InventoryExports.hpp are marked too large for the prepared folder. I read the changed regions of each through the pinned reader, but not their full text. The complete LegacyExports.hpp text was available but only its touched region was read. The review-folder exclusion listing was unavailable. The PR's reported module disassembly/harness checks, reported test commands, Windows behavior, and console behavior were not independently verified. Could not run the repository reader as a command or execute checks in this environment.
Files read: description.md, commits.md, manifest.json, diff.patch; changed source files include/LegacyExports.hpp, include/MessagePortChannelExports.hpp, libSceNKWebKit.hpp, src/MessagePortChannel.cpp, src/MessagePortChannelAbi.hpp, tests/MessagePortChannel.cpp, and docs/dev/debt/changes/feat-nkwebkit-message-port-channel.md; relevant changed regions of Export.cpp and include/InventoryExports.hpp. files.json was not available.
ABI layout and export declarations core/libs/prx/libSceNKWebKit/src/MessagePortChannelAbi.hpp, core/libs/prx/libSceNKWebKit/include/MessagePortChannelExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp
The new ABI structures define message-port and channel layouts with size and offset assertions. The export header declares both functions, and the library header includes it.
Export implementations and verification core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/{InventoryExports,LegacyExports}.hpp, core/libs/prx/libSceNKWebKit/src/MessagePortChannel.cpp, core/libs/prx/libSceNKWebKit/tests/MessagePortChannel.cpp, docs/dev/debt/changes/feat-nkwebkit-message-port-channel.md
The implementation looks up a process identifier for a port and checks for pending or in-flight messages. The former stubs and declarations are removed. Tests check layout and function results; the change record documents the exports and ABI details.
Suggested reviewers:privacyonion
Change: Feature
Merge Risk: Minimal · up to 26092
This change replaces two stubbed MessagePortChannel exports with working implementations backed by pinned ABI layouts and tests. No concrete merge-blocking risk was found in the supplied evidence.
Security architecture risk: Low · up to 26092
The two queries only read channel state and do not change ownership or permissions. The main risk is that they now rely on callers to provide valid channel objects: a wrong or stale object could cause a fault or an incorrect result. No path from untrusted input to either query was established.
Retained concerns
Trivial · security · inferred: The working exports introduce direct reads through caller-provided pointers where the base stubs performed none. If a deployed binding passes a stale or ABI-incompatible channel object, the calls can fault or return incorrect channel state. Whether an untrusted caller can violate that precondition remains unverified.
inferred — With valid ABI objects, the directly visible results are limited to one channel's stored process identifier and activity bit. The reviewed source does not establish that guest or web input can supply the pointers, or that a downstream consumer uses either result for authorization or lifecycle decisions.
Trust Boundaries and Controls
observed — The exports rely on callers to supply live, ABI-compatible objects. Compile-time assertions check the local layout; they do not validate the identity, lifetime, or provenance of objects passed at runtime.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.
The reason will be displayed to describe this comment to others. Learn more.
Architecture findings (1)
Advisory architecture findings (1)
Trivial — The working exports introduce direct reads through caller-provided pointers where the base stubs performed none. If a deployed binding passes a stale or ABI-incompatible channel object, the calls can fault or return incorrect channel state. Whether an untrusted caller can violate that precondition remains unverified.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 8be32171-de8d-4b31-b4b9-d38ce54820fc
Commits
Reviewing files that changed from the base of the PR and between aecfbf7 and 260920b.
The reason will be displayed to describe this comment to others. Learn more.
Reviewed — looks good
Nothing blocks this change; the inspected implementation and tests support merging.
What I ran
Reviewed head 260920b7d6a7c6aaaaf991fcdc3b5596efc1b799. I inspected the prepared diff and manifest, plus the pinned source for the changed functions. No test commands were run; reported test results below are from the PR description.
Results
Check
Result
Note
Patch review
passed
Export logic and ABI layout inspected
Tests
not run
Results reported by the author
Windows
not run
Reported by the author
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of Export.cpp was excluded by the review folder size rule; I read the relevant source ranges around the removed stubs. The changed header files InventoryExports.hpp and LegacyExports.hpp were listed as included but were not read. I did not inspect the test build registration, run the tests, verify the binary module or its offsets, or test on Windows or a console. The author reports the Linux test, conventions check, public headers audit, and merge-tree check passed.
Files read: description.md, commits.md, manifest.json, diff.patch, Export.cpp relevant ranges, and the added test, implementation, ABI, exports, and debt files as shown in the diff. Files excluded by the review folder: Export.cpp full text (too large). InventoryExports.hpp and LegacyExports.hpp were not inspected.
The reason will be displayed to describe this comment to others. Learn more.
Built the branch’s changed sources and ran MessagePortChannel on Linux against the existing runtime libraries. The test run passed and covered the process lookup and pending-or-in-flight state queries.
AI-assisted: yes.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Implements 2
libSceNKWebKitexports ofWebCore::MessagePortChannel. Both throwNotImplementedonmaintoday.processForPort(const MessagePortIdentifier&): returns the process entangled with the given port (m_processes[0]when the port equalsm_ports[0], otherwisem_processes[1]). Thestd::optional<ProcessIdentifier>comes back in registers: the value inrax, the engaged byte indl.hasAnyMessagesPendingOrInFlight() const: true whenm_messageBatchesInFlightis non-zero or either pending message vector is non-empty.Source: the
libSceNKWebKit.sprxwith SHA-2563af992253665387feeb5df90ff27dff683e3aa270cc4d92a0535b46ab18fa20d. The logic follows the pinned WebKitMessagePortChannel.cpp(licence notice kept). The object offsets come from the module's own code and match the pinnedMessagePortChannel.h: ports at0x8and0x18(16 bytes each), process slots at0x30and0x40(value plus engaged byte), pending message vector sizes at0x6cand0x7c, batches in flight at0xa0. They live in the newsrc/MessagePortChannelAbi.hpp.Only the fields the two functions read were checked against the module; the other members are laid out from the pinned header.
Debt: the fragment
docs/dev/debt/changes/feat-nkwebkit-message-port-channel.mdadds the Functional entry and removes thehasAnyMessagesPendingOrInFlightinventory row (processForPorthad no inventory row).Overlap: no open PR matches
MessagePortChannel, and on currentorigin/mainboth are still only theNotImplementedstubs.How it was checked
Offline, against the module's own code (none of it is in the repository): both function bodies were disassembled and their byte blobs run against this implementation in a harness.
In the repository, the new
nkwebkit_messageportchanneltest builds channel objects in memory and checks both exports, including a port matching in only one of its two words, an unengaged process slot, vector capacity without size, and the field offsets.Tested
Linux Mint 22.3, GCC 13.3, Release:
nkwebkit_messageportchannelpasses (100% of the 1 test selected).tools/check_conventions.pypasses.core/libs/tests/test_public_headers.py --audit-onlypasses.git merge-treeagainst currentorigin/mainis clean.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)Summary by CodeRabbit
New Features
Tests