fix(libSceNKWebKit): implement WTF StringImpl destruction #14917

Closed
w4rc0n wants to merge 3 commits from upstream-pr/14917 into main
w4rc0n commented 2026-11-02 01:31:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by w4rc0n on 2026-11-02T01:31:21Z.


What

WTF::StringImpl::destroy(StringImpl*) (_ZN3WTF10StringImpl7destroyEPS0_) was a parameterless throwing stub, so a guest deref that dropped the last reference to any string threw. It now frees the string as the pinned PS5 WebKit 11.x StringImpl::~StringImpl and destroy do for internal, owned and substring buffers, through the same path the host Release already used, so there is one implementation.

  • A null pointer or a string with an odd reference count (s_refCountFlagIsStaticString) throws std::invalid_argument.
  • Atom, symbol and external strings throw a std::runtime_error naming them, because their tables and callbacks aren't modelled yet; the debt entry records it.
  • The export takes its real prototype in WtfExports.hpp and leaves the inventory.

tools/pr_overlap.py on this head, with main at 0eba5db30d: no other open PR changes this export or WtfAbi::Release or adds the same files. For the PRs it couldn't compare because they no longer merge with main, GitHub's file lists show none of them changing this export or WtfAbi::Release either. #14172 and #15241 change nearby lines in the same files; whichever merges later keeps both sides. The only exports it shares are with #14918, #14919 and #14920, in the same stack.

Tested

Debian 12, GCC 12.2, Linux 6.18, Release, at the head 95dfdd5f7ea918208115e660db29009d06db3174, no local changes:

  • guest_nkwebkit_dates, guest_nkwebkit_numbers, nkwebkit_base, nkwebkit_config, nkwebkit_constants, nkwebkit_fastbitvector, nkwebkit_jsc, nkwebkit_palsessionid, nkwebkit_preferences, nkwebkit_resourceresponse, nkwebkit_webcoregeometry, nkwebkit_wtf, guest_nkwebkit_urls and public_headers pass. The new nkwebkit_wtf cases destroy, through the export, 8-bit and 16-bit internal strings, owned buffers on the host and guest paths, a string borrowing a literal (left untouched), and 8-bit and 16-bit substrings, whose owner gets its reference back.
  • tools/progress.py: libSceNKWebKit 1313 implemented (1312 on main), StringImpl::destroy among them.
  • tools/check_conventions.py passes.
  • Windows (GitHub-hosted CI in the author's fork): run 41376645467 built feat/nkwebkit-external-strings at its previous head 393806839235d0b091a64e87b0245cd757bd924a, which contains this PR's commit. It is AnyPS5's Build workflow, dispatched in the author's fork with select=true: the branch merged into main at 93dbd0f82aea684e95f15f06e7d42c0064af18cf, built on windows-latest with WinLibs GCC 15.2 (MinGW-w64, UCRT). None of the 672 selected tests failed; 6 AGC tests were skipped, which check_skips.py accepts. That includes the nine NKWebKit tests, public_headers and patched_libraries. The later rebases onto main (now 0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4, after #14479, #15228, #13766, #14925 and #15911) changed only docs/dev/debt/libSceNKWebKit.md, so git range-diff shows the code and tests under test are the same as at that run. A fork-internal pull request existed only to give the workflow a number.

Not built or run: macOS. No title or homebrew was run.

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
  • 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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5113579260 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14917). Originally posted by [w4rc0n](https://github.com/w4rc0n) on 2026-11-02T01:31:21Z. --- ### What `WTF::StringImpl::destroy(StringImpl*)` (`_ZN3WTF10StringImpl7destroyEPS0_`) was a parameterless throwing stub, so a guest `deref` that dropped the last reference to any string threw. It now frees the string as the [pinned PS5 WebKit 11.x `StringImpl::~StringImpl` and `destroy`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/StringImpl.cpp#L113-L157) do for internal, owned and substring buffers, through the same path the host `Release` already used, so there is one implementation. - A null pointer or a string with an odd reference count (`s_refCountFlagIsStaticString`) throws `std::invalid_argument`. - Atom, symbol and external strings throw a `std::runtime_error` naming them, because their tables and callbacks aren't modelled yet; the debt entry records it. - The export takes its real prototype in `WtfExports.hpp` and leaves the inventory. `tools/pr_overlap.py` on this head, with `main` at `0eba5db30d`: no other open PR changes this export or `WtfAbi::Release` or adds the same files. For the PRs it couldn't compare because they no longer merge with `main`, GitHub's file lists show none of them changing this export or `WtfAbi::Release` either. #14172 and #15241 change nearby lines in the same files; whichever merges later keeps both sides. The only exports it shares are with #14918, #14919 and #14920, in the same stack. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Debian 12, GCC 12.2, Linux 6.18, Release, at the head `95dfdd5f7ea918208115e660db29009d06db3174`, no local changes: - `guest_nkwebkit_dates`, `guest_nkwebkit_numbers`, `nkwebkit_base`, `nkwebkit_config`, `nkwebkit_constants`, `nkwebkit_fastbitvector`, `nkwebkit_jsc`, `nkwebkit_palsessionid`, `nkwebkit_preferences`, `nkwebkit_resourceresponse`, `nkwebkit_webcoregeometry`, `nkwebkit_wtf`, `guest_nkwebkit_urls` and `public_headers` pass. The new `nkwebkit_wtf` cases destroy, through the export, 8-bit and 16-bit internal strings, owned buffers on the host and guest paths, a string borrowing a literal (left untouched), and 8-bit and 16-bit substrings, whose owner gets its reference back. - `tools/progress.py`: libSceNKWebKit 1313 implemented (1312 on `main`), `StringImpl::destroy` among them. - `tools/check_conventions.py` passes. - **Windows (GitHub-hosted CI in the author's fork):** [run 41376645467](https://github.com/w4rc0n/AnyPS5/actions/runs/41376645467) built `feat/nkwebkit-external-strings` at its previous head `393806839235d0b091a64e87b0245cd757bd924a`, which contains this PR's commit. It is AnyPS5's `Build` workflow, dispatched in the author's fork with `select=true`: the branch merged into `main` at `93dbd0f82aea684e95f15f06e7d42c0064af18cf`, built on `windows-latest` with WinLibs GCC 15.2 (MinGW-w64, UCRT). None of the 672 selected tests failed; 6 AGC tests were skipped, which `check_skips.py` accepts. That includes the nine NKWebKit tests, `public_headers` and `patched_libraries`. The later rebases onto `main` (now `0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4`, after #14479, #15228, #13766, #14925 and #15911) changed only `docs/dev/debt/libSceNKWebKit.md`, so `git range-diff` shows the code and tests under test are the same as at that run. A fork-internal pull request existed only to give the workflow a number. Not built or run: macOS. No title or homebrew was run. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
BunnyFl commented 2026-11-02 03:36:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T03:36:11Z.

Review: APPROVED


Windows 11, WinLibs GCC 15.2.0 r7, Release. Head 18bf8fbc39 merged into upstream/main 93dbd0f82a:

  • nkwebkit_wtf, nkwebkit_base, nkwebkit_config, nkwebkit_jsc, nkwebkit_preferences, nkwebkit_webcoregeometry, guest_nkwebkit_dates, guest_nkwebkit_numbers, nkwebkit_constants and public_headers: 10/10 pass.
  • Mutation check: with Destroy no longer releasing a substring's owner (case 2), nkwebkit_wtf fails. It fails at line 685, an existing substring check, before it reaches the new TestDestroy. That is because the host Release and the export now share Destroy, which is the point of the change.

Read against the WebKit 11.x ~StringImpl/destroy you pin:

  • owned frees the data, substring derefs the owner stored at +24, internal frees only the impl;
  • atom, symbol and external strings, which need tables or callbacks AnyPS5 doesn't model, are refused rather than guessed.

The tests check what's added without pinning those refusals.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5731841684 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14917#pullrequestreview-5731841684). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T03:36:11Z. **Review:** APPROVED --- Windows 11, WinLibs GCC 15.2.0 r7, Release. Head 18bf8fbc39 merged into upstream/main 93dbd0f82a: - `nkwebkit_wtf`, `nkwebkit_base`, `nkwebkit_config`, `nkwebkit_jsc`, `nkwebkit_preferences`, `nkwebkit_webcoregeometry`, `guest_nkwebkit_dates`, `guest_nkwebkit_numbers`, `nkwebkit_constants` and `public_headers`: 10/10 pass. - Mutation check: with `Destroy` no longer releasing a substring's owner (case 2), `nkwebkit_wtf` fails. It fails at line 685, an existing substring check, before it reaches the new `TestDestroy`. That is because the host `Release` and the export now share `Destroy`, which is the point of the change. Read against the WebKit 11.x `~StringImpl`/`destroy` you pin: - owned frees the data, substring derefs the owner stored at +24, internal frees only the impl; - atom, symbol and external strings, which need tables or callbacks AnyPS5 doesn't model, are refused rather than guessed. The tests check what's added without pinning those refusals.
BunnyFl commented 2026-11-05 03:10:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-05T03:10:35Z.

Review: APPROVED


@w4rc0n re-checked after the force-push. 95dfdd5f7e is a rebase of 18bf8fbc39, the head I approved: git range-diff shows no change to any code or test line. The only differences are hunk context and the dropped edit of the "Additional callable exports" count line in docs/dev/debt/libSceNKWebKit.md, which main has since reworded.

On 95dfdd5f7e merged onto main 0540ef0ef2 (Windows 11, WinLibs GCC 15.2.0, Release, nkwebkit_wtf_tests rebuilt), nkwebkit_wtf passed, 1 of 1. With main's core/libs/prx/libSceNKWebKit/src/WtfString.cpp put back, nkwebkit_wtf_tests doesn't link: the test calls exports that only this PR defines. That shows the test needs the change, not what it checks; the behavioural check is the mutation from my earlier review, on the old head. check_conventions.py passes.

pr_overlap.py --branch: the rows with the same exports are your own #14918, #14919 and #14920 (stacked on this one through Depends on). The other comparable rows share lines in Export.cpp, the export headers or the debt file but no exports; I haven't checked each of them against this PR. The tool couldn't compare about 50 more PRs, which conflict with main.

Approving again at 95dfdd5f7e.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5779373174 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14917#pullrequestreview-5779373174). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-05T03:10:35Z. **Review:** APPROVED --- @w4rc0n re-checked after the force-push. `95dfdd5f7e` is a rebase of `18bf8fbc39`, the head I approved: `git range-diff` shows no change to any code or test line. The only differences are hunk context and the dropped edit of the "Additional callable exports" count line in `docs/dev/debt/libSceNKWebKit.md`, which `main` has since reworded. On `95dfdd5f7e` merged onto `main` `0540ef0ef2` (Windows 11, WinLibs GCC 15.2.0, Release, `nkwebkit_wtf_tests` rebuilt), `nkwebkit_wtf` passed, 1 of 1. With `main`'s `core/libs/prx/libSceNKWebKit/src/WtfString.cpp` put back, `nkwebkit_wtf_tests` doesn't link: the test calls exports that only this PR defines. That shows the test needs the change, not what it checks; the behavioural check is the mutation from my [earlier review](https://github.com/boykopovar/AnyPS5/pull/14917#pullrequestreview-5731841684), on the old head. `check_conventions.py` passes. `pr_overlap.py --branch`: the rows with the same exports are your own #14918, #14919 and #14920 (stacked on this one through `Depends on`). The other comparable rows share lines in `Export.cpp`, the export headers or the debt file but no exports; I haven't checked each of them against this PR. The tool couldn't compare about 50 more PRs, which conflict with `main`. Approving again at `95dfdd5f7e`. AI-assisted: yes (Claude Code)

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!14917
No description provided.