feat(libwebrtc): implement webrtc::PendingTaskSafetyFlag::Create #20025

Merged
Krille2004zzz merged 1 commit from upstream-pr/20025 into main 2026-11-14 14:58:55 +00:00
Krille2004zzz commented 2026-11-14 12:06:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Krille2004zzz on 2026-11-14T12:06:42Z.


What

Implements webrtc::PendingTaskSafetyFlag::Create (_ZN6webrtc21PendingTaskSafetyFlag6CreateEv) in libwebrtc:

  • Create returns rtc::scoped_refptr<PendingTaskSafetyFlag>. That type has a non-trivial destructor, so under the Itanium ABI it is returned through a hidden result pointer. The placeholder int(void) signature in Api.hpp now takes and returns that pointer.
  • It allocates the 8-byte flag with guest operator new (as CopyOnWriteBuffer does), sets the RefCountedNonVirtual count to 1 and alive_ to true, and writes the pointer to the result. A null result throws.
  • The guest frees the flag through its own scoped_refptr/Release, so the allocation goes through the guest allocator.

Follows public BSD-licensed WebRTC source at commit 8d78f5de6c27b2c793039989ea381f1428fb0100. Create is CreateInternal(true), which wraps new PendingTaskSafetyFlag(alive) in a scoped_refptr; its AddRef takes the count from 0 to 1. The code is the same at M127 (branch-heads/6533).

docs/dev/debt/libwebrtc.md gets a new entry listing what is unverified: the 8-byte layout with an empty main_sequence_ (an NDEBUG build), and the hidden result pointer. The unimplemented export count drops from 222 to 221.

Tested

Linux (Debian trixie, GCC 14.2), Release build with BUILD_TESTING=ON, rebased on current main. Not tested on a console, a title or Windows.

  • core/libs/prx/libwebrtc/tests/PendingTaskSafetyFlag.cpp now registers a tracking guest heap. It checks that Create returns the result pointer, allocates exactly 8 bytes, and sets count 1 and alive. It checks that two flags are independent through SetNotAlive/alive, that freeing both leaves no allocations, and that a null result throws.
  • ctest -R '[Ww]eb[Rr]tc|[Nn]ack|[Ss]afety|public_headers|export_gap|conventions|progress_report|test_registration|debt': 253/253 passed.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.
  • tools/pr_overlap.py --names _ZN6webrtc21PendingTaskSafetyFlag6CreateEv: stub on main, no open pull request.

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:5311056747 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20025). Originally posted by [Krille2004zzz](https://github.com/Krille2004zzz) on 2026-11-14T12:06:42Z. --- ### What Implements `webrtc::PendingTaskSafetyFlag::Create` (`_ZN6webrtc21PendingTaskSafetyFlag6CreateEv`) in libwebrtc: - `Create` returns `rtc::scoped_refptr<PendingTaskSafetyFlag>`. That type has a non-trivial destructor, so under the Itanium ABI it is returned through a hidden result pointer. The placeholder `int(void)` signature in `Api.hpp` now takes and returns that pointer. - It allocates the 8-byte flag with guest `operator new` (as `CopyOnWriteBuffer` does), sets the `RefCountedNonVirtual` count to 1 and `alive_` to true, and writes the pointer to the result. A null result throws. - The guest frees the flag through its own `scoped_refptr`/`Release`, so the allocation goes through the guest allocator. Follows public BSD-licensed WebRTC source at commit 8d78f5de6c27b2c793039989ea381f1428fb0100. `Create` is `CreateInternal(true)`, which wraps `new PendingTaskSafetyFlag(alive)` in a `scoped_refptr`; its `AddRef` takes the count from 0 to 1. The code is the same at M127 (`branch-heads/6533`). - https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/task_queue/pending_task_safety_flag.cc - https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/task_queue/pending_task_safety_flag.h - https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/ref_counted_base.h - https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/api/scoped_refptr.h `docs/dev/debt/libwebrtc.md` gets a new entry listing what is unverified: the 8-byte layout with an empty `main_sequence_` (an `NDEBUG` build), and the hidden result pointer. The unimplemented export count drops from 222 to 221. ### Tested Linux (Debian trixie, GCC 14.2), Release build with `BUILD_TESTING=ON`, rebased on current `main`. Not tested on a console, a title or Windows. - `core/libs/prx/libwebrtc/tests/PendingTaskSafetyFlag.cpp` now registers a tracking guest heap. It checks that `Create` returns the result pointer, allocates exactly 8 bytes, and sets count 1 and alive. It checks that two flags are independent through `SetNotAlive`/`alive`, that freeing both leaves no allocations, and that a null result throws. - `ctest -R '[Ww]eb[Rr]tc|[Nn]ack|[Ss]afety|public_headers|export_gap|conventions|progress_report|test_registration|debt'`: 253/253 passed. - `python3 tools/check_conventions.py --base origin/main`: all checks passed. - `tools/pr_overlap.py --names _ZN6webrtc21PendingTaskSafetyFlag6CreateEv`: stub on main, no open pull request. ### 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
MarcZX10 commented 2026-11-14 12:20:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T12:20:07Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation matches the described hidden result pointer and guest allocation behavior, with no verified blocking defect.

What I ran

Inspected the prepared diff and changed file contents at head 4149533e069e765a47549022767ee4c6f80a2797, plus allocator and test-registration context through repo_read.py. I ran no build or tests; test results in the description are author-reported.

Results

Check Result Note
Diff and changed source review passed All seven changed files read
Allocator and test wiring context passed Relevant implementations inspected
Build and tests not run No execution environment used
Console and Windows behavior not run Not verified here

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests were run, and console or Windows behavior was not confirmed. The author reports a Linux Release build and 253 passing selected tests; I did not independently verify those results. All files listed as included in the manifest were read: core/libs/prx/libwebrtc/CMakeLists.txt, core/libs/prx/libwebrtc/Export.cpp, core/libs/prx/libwebrtc/include/Api.hpp, core/libs/prx/libwebrtc/include/PendingTaskSafetyFlag.hpp, core/libs/prx/libwebrtc/src/PendingTaskSafetyFlag.cpp, core/libs/prx/libwebrtc/tests/PendingTaskSafetyFlag.cpp, and docs/dev/debt/libwebrtc.md. No files were listed as excluded in the manifest. The optional files.json listing was not available through the reader, so any exclusions described only there are not verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5904306371 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20025#pullrequestreview-5904306371). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T12:20:07Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation matches the described hidden result pointer and guest allocation behavior, with no verified blocking defect. ## What I ran Inspected the prepared diff and changed file contents at head `4149533e069e765a47549022767ee4c6f80a2797`, plus allocator and test-registration context through `repo_read.py`. I ran no build or tests; test results in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and changed source review | passed | All seven changed files read | | Allocator and test wiring context | passed | Relevant implementations inspected | | Build and tests | not run | No execution environment used | | Console and Windows behavior | not run | Not verified here | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No tests were run, and console or Windows behavior was not confirmed. The author reports a Linux Release build and 253 passing selected tests; I did not independently verify those results. All files listed as included in the manifest were read: `core/libs/prx/libwebrtc/CMakeLists.txt`, `core/libs/prx/libwebrtc/Export.cpp`, `core/libs/prx/libwebrtc/include/Api.hpp`, `core/libs/prx/libwebrtc/include/PendingTaskSafetyFlag.hpp`, `core/libs/prx/libwebrtc/src/PendingTaskSafetyFlag.cpp`, `core/libs/prx/libwebrtc/tests/PendingTaskSafetyFlag.cpp`, and `docs/dev/debt/libwebrtc.md`. No files were listed as excluded in the manifest. The optional `files.json` listing was not available through the reader, so any exclusions described only there are not verified. ## To get this to a good state Nothing is required.
PrivacyOnion commented 2026-11-14 12:54:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T12:54:56Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_webrtc_pending_task_safety_flag_tests built cleanly.
  • CTest (guest_webrtc_pending_task_safety_flag):
    1/1 Test #5141: guest_webrtc_pending_task_safety_flag ...   Passed    0.04 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libwebrtc/Export.cpp, core/libs/prx/libwebrtc/include/Api.hpp, core/libs/prx/libwebrtc/include/PendingTaskSafetyFlag.hpp, core/libs/prx/libwebrtc/src/PendingTaskSafetyFlag.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libwebrtc/src/PendingTaskSafetyFlag.cpp: verified _ZN6webrtc21PendingTaskSafetyFlag6CreateEv_nid_postfix validates result != nullptr and throws std::invalid_argument before dereference.
    • core/libs/prx/libwebrtc/include/Api.hpp and PendingTaskSafetyFlag.cpp: verified Itanium ABI hidden result pointer signature WebRtcPendingTaskSafetyFlag** returning result matches scoped_refptr non-trivial destructor conventions.
    • core/libs/prx/libwebrtc/include/PendingTaskSafetyFlag.hpp: verified struct WebRtcPendingTaskSafetyFlag layout (refCount at 0, alive at 4, sizeof 8) with static_asserts and verified guest operator new allocation (_Znwm_nid_postfix) initializes refCount to 1 and alive to true.
    • core/libs/prx/libwebrtc/Export.cpp and docs/dev/debt/libwebrtc.md: verified removal of unimplemented stub, decrement of unimplemented export count from 222 to 221, and documentation of unverified console layout and closure criteria.
    • core/libs/prx/libwebrtc/tests/PendingTaskSafetyFlag.cpp: verified test coverage for hidden result pointer return, 8-byte guest heap allocation tracking, flag independence via SetNotAlive, cleanup via _ZdlPv_nid_postfix, and null result exception handling.
    • AGENTS.md compliance: verified zero comments in code, correct CMake environment modification for Windows test libc loading in CMakeLists.txt, and strict adherence to repository conventions.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5904419156 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20025#pullrequestreview-5904419156). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T12:54:56Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `4149533e06`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_webrtc_pending_task_safety_flag_tests` built cleanly. - **CTest** (`guest_webrtc_pending_task_safety_flag`): ``` 1/1 Test #5141: guest_webrtc_pending_task_safety_flag ... Passed 0.04 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libwebrtc/Export.cpp`, `core/libs/prx/libwebrtc/include/Api.hpp`, `core/libs/prx/libwebrtc/include/PendingTaskSafetyFlag.hpp`, `core/libs/prx/libwebrtc/src/PendingTaskSafetyFlag.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libwebrtc/src/PendingTaskSafetyFlag.cpp: verified _ZN6webrtc21PendingTaskSafetyFlag6CreateEv_nid_postfix validates result != nullptr and throws std::invalid_argument before dereference. - core/libs/prx/libwebrtc/include/Api.hpp and PendingTaskSafetyFlag.cpp: verified Itanium ABI hidden result pointer signature WebRtcPendingTaskSafetyFlag** returning result matches scoped_refptr non-trivial destructor conventions. - core/libs/prx/libwebrtc/include/PendingTaskSafetyFlag.hpp: verified struct WebRtcPendingTaskSafetyFlag layout (refCount at 0, alive at 4, sizeof 8) with static_asserts and verified guest operator new allocation (_Znwm_nid_postfix) initializes refCount to 1 and alive to true. - core/libs/prx/libwebrtc/Export.cpp and docs/dev/debt/libwebrtc.md: verified removal of unimplemented stub, decrement of unimplemented export count from 222 to 221, and documentation of unverified console layout and closure criteria. - core/libs/prx/libwebrtc/tests/PendingTaskSafetyFlag.cpp: verified test coverage for hidden result pointer return, 8-byte guest heap allocation tracking, flag independence via SetNotAlive, cleanup via _ZdlPv_nid_postfix, and null result exception handling. - AGENTS.md compliance: verified zero comments in code, correct CMake environment modification for Windows test libc loading in CMakeLists.txt, and strict adherence to repository conventions. - Note: the AI-assisted checkbox can stay. Looks Good To Me
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!20025
No description provided.