feat(libSceNKWebKit): implement WTF::RunLoop and RunLoop::TimerBase on the generic event loop #23847

Closed
opxdelwin wants to merge 3 commits from upstream-pr/23847 into main
opxdelwin commented 2026-11-19 19:16:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by opxdelwin on 2026-11-19T19:16:18Z.




What

Implements 16 WTF::RunLoop exports from the 11.x inventory: main, current, dispatch, dispatchAfter, run, stop, cycle, setWakeUpCallback, suspendFunctionDispatchForCurrentCycle, plus RunLoop::TimerBase (C2 constructor, D1/D2 destructors, start, stop, isActive, secondsUntilFire). They are ported from the generic event loop the PlayStation port builds (RunLoop.cpp, generic/RunLoopGeneric.cpp, MainThread.cpp, playstation/WKRunLoop.cpp at neonmodder123/PS5-WebKit-11.x@80f77e94c63ee7202eec3d4b5b1a021dd89011ba). Each derived file carries its upstream licence notice and a Derived from line.

The WKRunLoop* C API (src/RunLoop.cpp) and callOnMainThread / callOnMainRunLoop with their AndWait forms (src/WtfMainThread.cpp) now run on RunLoop::main(), the same way they do upstream. Guest code that uses RunLoop, timers or callOnMainThread now shares one ordered main queue.

The guest-visible layout is pinned with static_asserts: TimerBase is 24 bytes, DispatchTimer is 40 (refcount at 24, function at 32) and the RunLoop refcount is at 8. I checked these with a probe built under g++ and clang++.

Behaviour change: WKRunLoopStopMain() with no loop running is now a no-op, because upstream's stop() returns when no loop is running. So the StopMain(); RunMain(); sequence in tests/Base.cpp would block, and I removed that WKRunLoopRunMain() line. TestStopWithoutRunningLoop covers the new behaviour, and the debt entry records it.

These stay throwing: the libSceJsc copies of WTF::RunLoop and TimerBase (a separate module with its own WTF). The debt fragment docs/dev/debt/changes/feat-libscenkwebkit-wtf-run-loop.md records them, together with the unverified console layout of private members, AndWait blocking when no loop runs, and the leak of a stopped dispatchAfter timer.

Tested

Homebrew/unit tests only, no title. Linux (Docker, Ubuntu image), targets libSceNKWebKit nkwebkit_wtfrunloop_tests nkwebkit_wtfcallonmain_tests nkwebkit_base_tests nkwebkit_mainthread_tests nkwebkit_forwarding_tests nkwebkit_symbolset_tests, ctest -R '^(nkwebkit_wtfrunloop|nkwebkit_wtfcallonmain|nkwebkit_base|nkwebkit_mainthread|nkwebkit_forwarding|nkwebkit_symbolset|public_headers.*)$':

  • GCC: 71/71 passed on 4a22d71, after rebasing onto main 23786c4e4f.
  • Clang: 66/71 passed, run before the rebase on main 735a3163fd. Every nkwebkit test passed. The 5 failures are public_headers_compile_* batches failing on -Winvalid-offsetof for Region in RegionExports.hpp. Main fails the same 5 batches with the same errors in the same container, so they are pre-existing.
  • tools/check_conventions.py and tools/debt_fold.py --check pass.

On fada67ccbb (exceptions thrown from run loop callbacks, plus new tests), Windows 11, MSYS2 UCRT64, GCC, Release, -DBUILD_TESTING=ON:

  • nkwebkit_wtfrunloop and nkwebkit_base passed; nkwebkit_wtfrunloop passed 100/100 repeated runs.
  • Negative control: without the RunImpl change, TestThrowingFunctionLeavesRun hangs in the second run().
  • tools/check_conventions.py passes.
  • Clang and Linux were not rerun on fada67ccbb.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5401354221 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23847). Originally posted by [opxdelwin](https://github.com/opxdelwin) on 2026-11-19T19:16:18Z. ---  ### What Implements 16 `WTF::RunLoop` exports from the 11.x inventory: `main`, `current`, `dispatch`, `dispatchAfter`, `run`, `stop`, `cycle`, `setWakeUpCallback`, `suspendFunctionDispatchForCurrentCycle`, plus `RunLoop::TimerBase` (C2 constructor, D1/D2 destructors, `start`, `stop`, `isActive`, `secondsUntilFire`). They are ported from the generic event loop the PlayStation port builds (`RunLoop.cpp`, `generic/RunLoopGeneric.cpp`, `MainThread.cpp`, `playstation/WKRunLoop.cpp` at `neonmodder123/PS5-WebKit-11.x@80f77e94c63ee7202eec3d4b5b1a021dd89011ba`). Each derived file carries its upstream licence notice and a `Derived from` line. The `WKRunLoop*` C API (`src/RunLoop.cpp`) and `callOnMainThread` / `callOnMainRunLoop` with their `AndWait` forms (`src/WtfMainThread.cpp`) now run on `RunLoop::main()`, the same way they do upstream. Guest code that uses `RunLoop`, timers or `callOnMainThread` now shares one ordered main queue. The guest-visible layout is pinned with `static_assert`s: `TimerBase` is 24 bytes, `DispatchTimer` is 40 (refcount at 24, function at 32) and the `RunLoop` refcount is at 8. I checked these with a probe built under g++ and clang++. Behaviour change: `WKRunLoopStopMain()` with no loop running is now a no-op, because upstream's `stop()` returns when no loop is running. So the `StopMain(); RunMain();` sequence in `tests/Base.cpp` would block, and I removed that `WKRunLoopRunMain()` line. `TestStopWithoutRunningLoop` covers the new behaviour, and the debt entry records it. These stay throwing: the libSceJsc copies of `WTF::RunLoop` and `TimerBase` (a separate module with its own WTF). The debt fragment `docs/dev/debt/changes/feat-libscenkwebkit-wtf-run-loop.md` records them, together with the unverified console layout of private members, `AndWait` blocking when no loop runs, and the leak of a stopped `dispatchAfter` timer. ### 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. --> Homebrew/unit tests only, no title. Linux (Docker, Ubuntu image), targets `libSceNKWebKit nkwebkit_wtfrunloop_tests nkwebkit_wtfcallonmain_tests nkwebkit_base_tests nkwebkit_mainthread_tests nkwebkit_forwarding_tests nkwebkit_symbolset_tests`, `ctest -R '^(nkwebkit_wtfrunloop|nkwebkit_wtfcallonmain|nkwebkit_base|nkwebkit_mainthread|nkwebkit_forwarding|nkwebkit_symbolset|public_headers.*)$'`: - GCC: 71/71 passed on `4a22d71`, after rebasing onto main `23786c4e4f`. - Clang: 66/71 passed, run before the rebase on main `735a3163fd`. Every nkwebkit test passed. The 5 failures are `public_headers_compile_*` batches failing on `-Winvalid-offsetof` for `Region` in `RegionExports.hpp`. Main fails the same 5 batches with the same errors in the same container, so they are pre-existing. - `tools/check_conventions.py` and `tools/debt_fold.py --check` pass. On `fada67ccbb` (exceptions thrown from run loop callbacks, plus new tests), Windows 11, MSYS2 UCRT64, GCC, Release, `-DBUILD_TESTING=ON`: - `nkwebkit_wtfrunloop` and `nkwebkit_base` passed; `nkwebkit_wtfrunloop` passed 100/100 repeated runs. - Negative control: without the `RunImpl` change, `TestThrowingFunctionLeavesRun` hangs in the second `run()`. - `tools/check_conventions.py` passes. - Clang and Linux were not rerun on `fada67ccbb`. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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
PrivacyOnion commented 2026-11-19 19:43:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T19:43:54Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against eb4667a936:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_base_tests, nkwebkit_wtfrunloop_tests built cleanly.
  • CTest (nkwebkit_base, nkwebkit_wtfrunloop):
    1/2 Test #4634: nkwebkit_base ....................   Passed    0.06 sec
    2/2 Test #4774: nkwebkit_wtfrunloop ..............   Passed    0.24 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/RunLoop.cpp, core/libs/prx/libSceNKWebKit/src/WtfFunctionAbi.hpp, core/libs/prx/libSceNKWebKit/src/WtfMainThread.cpp, core/libs/prx/libSceNKWebKit/src/WtfRunLoop.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified WtfRunLoopAbi.hpp layout against WebKit 11.x upstream and static_asserts (TimerBase 24B, DispatchTimer 40B, RunLoop 24B, RunLoopCycleResult 4B).
    • Checked synchronization and lock scoping in WtfRunLoop.cpp (loopLock, nextIterationLock, PopulateTasks wait logic, stopCondition).
    • Audited WtfMainThread.cpp callOnMainThread / callOnMainRunLoop / CallOnMainAndWait exception safety and future/promise lifetimes.
    • Verified memory management in DispatchTimerRef, ScheduledTaskRef, and OwnedFunction destructors/vtable deletingDestructor calls.
    • Checked AGENTS.md compliance, upstream licence headers, debt change fragments, and conventions.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5982107107 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23847#pullrequestreview-5982107107). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T19:43:54Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `eb4667a936`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_base_tests`, `nkwebkit_wtfrunloop_tests` built cleanly. - **CTest** (`nkwebkit_base`, `nkwebkit_wtfrunloop`): ``` 1/2 Test #4634: nkwebkit_base .................... Passed 0.06 sec 2/2 Test #4774: nkwebkit_wtfrunloop .............. Passed 0.24 sec 100% tests passed, 0 tests failed out of 2 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/RunLoop.cpp`, `core/libs/prx/libSceNKWebKit/src/WtfFunctionAbi.hpp`, `core/libs/prx/libSceNKWebKit/src/WtfMainThread.cpp`, `core/libs/prx/libSceNKWebKit/src/WtfRunLoop.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified WtfRunLoopAbi.hpp layout against WebKit 11.x upstream and static_asserts (TimerBase 24B, DispatchTimer 40B, RunLoop 24B, RunLoopCycleResult 4B). - Checked synchronization and lock scoping in WtfRunLoop.cpp (loopLock, nextIterationLock, PopulateTasks wait logic, stopCondition). - Audited WtfMainThread.cpp callOnMainThread / callOnMainRunLoop / CallOnMainAndWait exception safety and future/promise lifetimes. - Verified memory management in DispatchTimerRef, ScheduledTaskRef, and OwnedFunction destructors/vtable deletingDestructor calls. - Checked AGENTS.md compliance, upstream licence headers, debt change fragments, and conventions. Looks Good To Me
MarcZX10 commented 2026-11-21 07:34:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:34:28Z.

Review: DISMISSED


Reviewed — changes requested

Changes are required before merge: remove the loop’s stack-local status from mainLoops on every exit, including normal returns and callback exceptions.

What I ran

Reviewed head eb4667a93619ebc4d386acedd8c82f1318384074. This was a source review only; no test commands were run. The author reports GCC tests passed after rebasing and Clang tests ran before the rebase.

Results

Check Result Note
Source review failed Found stale loop status after exceptions
Tests in this review not run No commands run
Console behavior not run Author reports it is unverified

Findings

Blocking

  • core/libs/prx/libSceNKWebKit/src/WtfRunLoop.cpp:414: RunImpl stores the address of stack-local statusOfThisLoop in mainLoops, but only removes it when PopulateTasks returns false or in the catch handler. If a dispatched function or timer callback throws, a later stop() can dereference the stale pointer at WtfRunLoop.cpp:600, causing undefined behavior. Ensure the status is removed on every exit, for example with scope-based cleanup, and add a regression test that throws from a callback and then exercises the loop again.

Non-blocking

  • core/libs/prx/libSceNKWebKit/src/WtfRunLoop.cpp:580: the internal dispatchAfter callback holds a timer reference until it runs. Stopping the timer before it fires prevents that callback from running and leaves the captured reference alive. The debt entry explicitly documents this limitation.

Not verified

  • No tests or builds were run during this review; no negative control was run.
  • Console execution and private-member layout were not verified.
  • Read all changed-line content available in the review bundle. Export.cpp and include/InventoryExports.hpp were excluded from the bundle and read only around the affected export entries through the pinned reader. No other changed files were excluded.

To get this to a good state

  • Make RunImpl remove its status from mainLoops on every exit and add a regression test for a throwing callback. Rerun the reported GCC and Clang test selections on the resulting head.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003857801 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23847#pullrequestreview-6003857801). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T07:34:28Z. **Review:** DISMISSED --- # Reviewed — changes requested Changes are required before merge: remove the loop’s stack-local status from `mainLoops` on every exit, including normal returns and callback exceptions. ## What I ran Reviewed head `eb4667a93619ebc4d386acedd8c82f1318384074`. This was a source review only; no test commands were run. The author reports GCC tests passed after rebasing and Clang tests ran before the rebase. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | Found stale loop status after exceptions | | Tests in this review | not run | No commands run | | Console behavior | not run | Author reports it is unverified | ## Findings ### Blocking - `core/libs/prx/libSceNKWebKit/src/WtfRunLoop.cpp:414`: `RunImpl` stores the address of stack-local `statusOfThisLoop` in `mainLoops`, but only removes it when `PopulateTasks` returns false or in the catch handler. If a dispatched function or timer callback throws, a later `stop()` can dereference the stale pointer at `WtfRunLoop.cpp:600`, causing undefined behavior. Ensure the status is removed on every exit, for example with scope-based cleanup, and add a regression test that throws from a callback and then exercises the loop again. ### Non-blocking - `core/libs/prx/libSceNKWebKit/src/WtfRunLoop.cpp:580`: the internal `dispatchAfter` callback holds a timer reference until it runs. Stopping the timer before it fires prevents that callback from running and leaves the captured reference alive. The debt entry explicitly documents this limitation. ## Not verified - No tests or builds were run during this review; no negative control was run. - Console execution and private-member layout were not verified. - Read all changed-line content available in the review bundle. `Export.cpp` and `include/InventoryExports.hpp` were excluded from the bundle and read only around the affected export entries through the pinned reader. No other changed files were excluded. ## To get this to a good state - Make `RunImpl` remove its status from `mainLoops` on every exit and add a regression test for a throwing callback. Rerun the reported GCC and Clang test selections on the resulting head.
MarcZX10 commented 2026-11-22 06:28:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T06:28:21Z.

Review: COMMENTED


Reviewed — comments

Nothing is required; the points below are optional.

What I ran

Reviewed head 4a22d71db8376c82ffa2337b696b2bd31c2dbc45 using the prepared diff and repo_read.py for targeted source context. No commands or tests were run by me.

Results

Check Result Note
Diff and targeted source review passed Event loop, ABI, and caller paths inspected
Programmatic checks not run Author-reported results are not independently verified
Physical console behavior not run The description says console layout is unverified

Findings

Blocking

None.

Non-blocking

  • InitializeMainRunLoop() uses compare_exchange_strong and throws if initialization has already occurred, but it is called inside std::call_once in _ZN3WTF20initializeMainThreadEv. A repeated call to the public initialization entry point therefore throws even though the previous implementation and std::call_once indicate initialization should be idempotent. Consider making the run loop initialization idempotent as well. Evidence: core/libs/prx/libSceNKWebKit/src/WtfRunLoop.cpp:538 and core/libs/prx/libSceNKWebKit/src/WtfMainThread.cpp:97.

Not verified

  • The reader’s review folder lists 12 changed files; all 10 files with added lines and full text available were read, including WtfRunLoop.cpp, its ABI and ownership helpers, and the test source. Export.cpp and InventoryExports.hpp are listed as excluded because they are too large; their deletions are visible in the prepared diff, but their complete contents were not read.
  • Tests, builds, conventions checks, debt checks, Windows behavior, and physical-console behavior were not run or independently confirmed. The description reports Linux results and explicitly says Windows and console behavior were not tested.
  • The 5 reported Clang public-header failures and the claim that main has the same failures were not independently checked.

To get this to a good state

Nothing is required. Optionally, make repeated main-thread initialization idempotent and add coverage for calling it more than once.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6010765274 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23847#pullrequestreview-6010765274). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T06:28:21Z. **Review:** COMMENTED --- # Reviewed — comments Nothing is required; the points below are optional. ## What I ran Reviewed head `4a22d71db8376c82ffa2337b696b2bd31c2dbc45` using the prepared diff and `repo_read.py` for targeted source context. No commands or tests were run by me. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | Event loop, ABI, and caller paths inspected | | Programmatic checks | not run | Author-reported results are not independently verified | | Physical console behavior | not run | The description says console layout is unverified | ## Findings ### Blocking None. ### Non-blocking - `InitializeMainRunLoop()` uses `compare_exchange_strong` and throws if initialization has already occurred, but it is called inside `std::call_once` in `_ZN3WTF20initializeMainThreadEv`. A repeated call to the public initialization entry point therefore throws even though the previous implementation and `std::call_once` indicate initialization should be idempotent. Consider making the run loop initialization idempotent as well. Evidence: `core/libs/prx/libSceNKWebKit/src/WtfRunLoop.cpp:538` and `core/libs/prx/libSceNKWebKit/src/WtfMainThread.cpp:97`. ## Not verified - The reader’s review folder lists 12 changed files; all 10 files with added lines and full text available were read, including `WtfRunLoop.cpp`, its ABI and ownership helpers, and the test source. `Export.cpp` and `InventoryExports.hpp` are listed as excluded because they are too large; their deletions are visible in the prepared diff, but their complete contents were not read. - Tests, builds, conventions checks, debt checks, Windows behavior, and physical-console behavior were not run or independently confirmed. The description reports Linux results and explicitly says Windows and console behavior were not tested. - The 5 reported Clang public-header failures and the claim that main has the same failures were not independently checked. ## To get this to a good state Nothing is required. Optionally, make repeated main-thread initialization idempotent and add coverage for calling it more than once.
MarcZX10 commented 2026-11-24 22:56:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-24T22:56:12Z.

Review: COMMENTED


Reviewed — comments

The run loop implementation and its tests were reviewed at head fada67ccbb17c795ebbccfc8679b6d0b0baea1b6; a verified timer lifetime defect remains, while the declared test runs were author-reported and not rerun here.

What I ran

No commands or tests were run. I inspected the prepared diff and selected changed files through the pinned repository reader.

Results

Check Result Note
Diff and targeted source review passed Core timer and callback paths inspected
Tests not run Only author-reported results were available
Full changed-line review not run Two large files and some changed ranges were not inspected

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceNKWebKit/src/WtfRunLoop.cpp:410: A repeating timer’s callback can destroy its own TimerBase. RunLoopScheduledTask remains alive through ScheduledTaskRef, but its timer pointer then refers to the destroyed object. After the callback returns, the loop can reinsert that task, and the next firing dereferences the dangling pointer at line 92. Ensure the scheduled task is deactivated when its owner is destroyed, and prevent reinsertion after destruction; add a regression test where a repeating timer destroys itself from fired.

Not verified

The full text and changed lines of Export.cpp and include/InventoryExports.hpp were excluded from the review folder and not read through the reader. I did not inspect every changed line in the included files, the build configuration/callers, or run any checks. The author reports GCC tests and Windows tests, but those results were not independently verified.

To get this to a good state

Nothing is required for this comment-only verdict. The timer lifetime issue is an optional point for the author to address before relying on self-destroying repeating timers.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6048696737 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23847#pullrequestreview-6048696737). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-24T22:56:12Z. **Review:** COMMENTED --- # Reviewed — comments The run loop implementation and its tests were reviewed at head `fada67ccbb17c795ebbccfc8679b6d0b0baea1b6`; a verified timer lifetime defect remains, while the declared test runs were author-reported and not rerun here. ## What I ran No commands or tests were run. I inspected the prepared diff and selected changed files through the pinned repository reader. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | Core timer and callback paths inspected | | Tests | not run | Only author-reported results were available | | Full changed-line review | not run | Two large files and some changed ranges were not inspected | ## Findings ### Blocking None. ### Non-blocking - `core/libs/prx/libSceNKWebKit/src/WtfRunLoop.cpp:410`: A repeating timer’s callback can destroy its own `TimerBase`. `RunLoopScheduledTask` remains alive through `ScheduledTaskRef`, but its `timer` pointer then refers to the destroyed object. After the callback returns, the loop can reinsert that task, and the next firing dereferences the dangling pointer at line 92. Ensure the scheduled task is deactivated when its owner is destroyed, and prevent reinsertion after destruction; add a regression test where a repeating timer destroys itself from `fired`. ## Not verified The full text and changed lines of `Export.cpp` and `include/InventoryExports.hpp` were excluded from the review folder and not read through the reader. I did not inspect every changed line in the included files, the build configuration/callers, or run any checks. The author reports GCC tests and Windows tests, but those results were not independently verified. ## To get this to a good state Nothing is required for this comment-only verdict. The timer lifetime issue is an optional point for the author to address before relying on self-destroying repeating timers.
MarcZX10 commented 2026-11-25 03:59:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T03:59:37Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the points below are optional.

What I ran

Reviewed head c59713f9136a8e36e67ad21c67d4afd5b63ac3dd. No commands or tests were run in this review session. I read the prepared description, commits, diff, manifest, and the complete head text of all changed files except Export.cpp and include/InventoryExports.hpp, whose full text was excluded as too large. I read targeted ranges of WtfRunLoop.cpp, WtfMainThread.cpp, RunLoop.cpp, and WtfFunctionAbi.hpp through repo_read.py.

Results

Check Result Note
Patch review passed Core loop and adapters inspected
Tests in this session not run Description reports author-run checks
Excluded full files not run Two large files unavailable in review folder

Findings

Blocking

None identified in the code read.

Non-blocking

  • WKRunLoopCallOnMainThread packages its callback in OwnedFunction and passes it into callOnMainThread (core/libs/prx/libSceNKWebKit/src/RunLoop.cpp:50). If the RunLoop::main() lookup or dispatch throws before taking ownership, the local owner releases the wrapper while the captured raw pointer remains in callback; this path is worth covering or making ownership transfer exception safe.

Not verified

  • Full contents of core/libs/prx/libSceNKWebKit/Export.cpp and core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp were excluded by the prepared review folder; only their diff hunks were read.
  • No tests were run here. The description reports Linux GCC and Windows GCC test results; those are author-reported, not independently verified.
  • Console behavior and guest ABI layout remain unverified as stated in the description.

To get this to a good state

Nothing is required. Optional: add coverage for callback ownership when main-loop lookup or dispatch fails before consuming the function.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6051665403 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23847#pullrequestreview-6051665403). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T03:59:37Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the points below are optional. ## What I ran Reviewed head `c59713f9136a8e36e67ad21c67d4afd5b63ac3dd`. No commands or tests were run in this review session. I read the prepared description, commits, diff, manifest, and the complete head text of all changed files except `Export.cpp` and `include/InventoryExports.hpp`, whose full text was excluded as too large. I read targeted ranges of `WtfRunLoop.cpp`, `WtfMainThread.cpp`, `RunLoop.cpp`, and `WtfFunctionAbi.hpp` through `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Patch review | passed | Core loop and adapters inspected | | Tests in this session | not run | Description reports author-run checks | | Excluded full files | not run | Two large files unavailable in review folder | ## Findings ### Blocking None identified in the code read. ### Non-blocking - `WKRunLoopCallOnMainThread` packages its callback in `OwnedFunction` and passes it into `callOnMainThread` (`core/libs/prx/libSceNKWebKit/src/RunLoop.cpp:50`). If the `RunLoop::main()` lookup or dispatch throws before taking ownership, the local owner releases the wrapper while the captured raw pointer remains in `callback`; this path is worth covering or making ownership transfer exception safe. ## Not verified - Full contents of `core/libs/prx/libSceNKWebKit/Export.cpp` and `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp` were excluded by the prepared review folder; only their diff hunks were read. - No tests were run here. The description reports Linux GCC and Windows GCC test results; those are author-reported, not independently verified. - Console behavior and guest ABI layout remain unverified as stated in the description. ## To get this to a good state Nothing is required. Optional: add coverage for callback ownership when main-loop lookup or dispatch fails before consuming the function.
ligmaSec commented 2026-12-03 12:52:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:52:06Z.

Review: COMMENTED


Built the branch’s RunLoop changes and ran the focused WtfRunLoop fixture on Linux against the existing runtime libraries. It passed. The broader Base fixture also built but aborted in this standalone setup, so its coverage remains unresolved.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170167377 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23847#pullrequestreview-6170167377). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T12:52:06Z. **Review:** COMMENTED --- Built the branch’s RunLoop changes and ran the focused WtfRunLoop fixture on Linux against the existing runtime libraries. It passed. The broader Base fixture also built but aborted in this standalone setup, so its coverage remains unresolved. AI-assisted: yes.

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!23847
No description provided.