feat(libwebrtc): implement absl FastIntToBuffer for int #13687

Merged
alvaroelpob merged 3 commits from upstream-pr/13687 into main 2026-10-31 19:18:16 +00:00
alvaroelpob commented 2026-10-30 23:56:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-30T23:56:23Z.


What

Implements absl::numbers_internal::FastIntToBuffer(int, char*) in libwebrtc, which threw and was declared without parameters.

The module's exact WebRTC revision is not known. Its rtc:: names (moved to webrtc:: from M135) and the PushResampler<short>::Resample(InterleavedView…) overloads (added in M127) place it between M127 branch-heads/6533 and M134 branch-heads/6998. The export name has no abseil inline namespace, which matches the Chromium abseil that WebRTC pins in DEPS. Both ends pin abseil at 65ef38d368 and d212a71416, and FastIntToBuffer(int32_t), EncodeFullU32, EncodeHundred and PrepareEightDigits are the same in both.

The behaviour follows that code. The function writes a - for negative values, then the decimal digits and a NUL, and returns a pointer to the NUL. For magnitudes from 10 to 99999999, EncodeFullU32 does an 8-byte little-endian store with the digits shifted down, so the bytes after the digits are zero up to 8 bytes from the first digit. The implementation zeroes the same bytes. Abseil declares the buffer absl::Nonnull<char*> and writes through it, so null is outside its contract. As a host-side defensive check, not console parity, a null buffer throws std::invalid_argument instead of faulting.

The library had no CMakeLists.txt, so this PR adds one that builds the same target as the generic rule in core/libs/CMakeLists.txt and registers the test. The debt file records the revision range and the source, and the inventory drops from 412 to 411.

Tested

Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with BUILD_TESTING=ON.

  • New guest_webrtc_fast_int_to_buffer test: on a buffer filled with x, 0, 7, -7, 10, -10, 123, -4567, 1234567, 99999999, -99999999, 100000000, 1234567890, INT_MAX and INT_MIN produce their decimal text and a NUL, and the returned pointer is the NUL. Bytes after the NUL are zero up to 8 bytes from the first digit for magnitudes from 10 to 99999999, and every byte after that is untouched. The defensive check is covered too: a null buffer throws std::invalid_argument.
  • Full ctest -j16 on head 314a8c5b49: 3030/3030 pass. check_conventions.py --base upstream/main passes. pr_overlap.py reports no overlap with open pull requests.
  • Not tested: Windows, a title.

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:5092608637 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13687). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-30T23:56:23Z. --- ### What Implements `absl::numbers_internal::FastIntToBuffer(int, char*)` in libwebrtc, which threw and was declared without parameters. The module's exact WebRTC revision is not known. Its `rtc::` names (moved to `webrtc::` from M135) and the `PushResampler<short>::Resample(InterleavedView…)` overloads (added in M127) place it between [M127 branch-heads/6533](https://webrtc.googlesource.com/src/+/e0b28a6a81a989c1f5c89e30fcd247870047390d) and [M134 branch-heads/6998](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100). The export name has no abseil inline namespace, which matches the Chromium abseil that WebRTC pins in `DEPS`. Both ends pin abseil at [65ef38d368](https://chromium.googlesource.com/chromium/src/third_party/+/65ef38d36813d1ad9d4cbf8a18b32ac3691f418b/abseil-cpp/absl/strings/numbers.cc) and [d212a71416](https://chromium.googlesource.com/chromium/src/third_party/+/d212a71416ad7c6ceca04d6d27dfdd84fd00c04c/abseil-cpp/absl/strings/numbers.cc), and `FastIntToBuffer(int32_t)`, `EncodeFullU32`, `EncodeHundred` and `PrepareEightDigits` are the same in both. The behaviour follows that code. The function writes a `-` for negative values, then the decimal digits and a NUL, and returns a pointer to the NUL. For magnitudes from 10 to 99999999, `EncodeFullU32` does an 8-byte little-endian store with the digits shifted down, so the bytes after the digits are zero up to 8 bytes from the first digit. The implementation zeroes the same bytes. Abseil declares the buffer `absl::Nonnull<char*>` and writes through it, so null is outside its contract. As a host-side defensive check, not console parity, a null buffer throws `std::invalid_argument` instead of faulting. The library had no `CMakeLists.txt`, so this PR adds one that builds the same target as the generic rule in `core/libs/CMakeLists.txt` and registers the test. The debt file records the revision range and the source, and the inventory drops from 412 to 411. ### 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. --> Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with `BUILD_TESTING=ON`. - New `guest_webrtc_fast_int_to_buffer` test: on a buffer filled with `x`, 0, 7, -7, 10, -10, 123, -4567, 1234567, 99999999, -99999999, 100000000, 1234567890, `INT_MAX` and `INT_MIN` produce their decimal text and a NUL, and the returned pointer is the NUL. Bytes after the NUL are zero up to 8 bytes from the first digit for magnitudes from 10 to 99999999, and every byte after that is untouched. The defensive check is covered too: a null buffer throws `std::invalid_argument`. - Full `ctest -j16` on head 314a8c5b49: 3030/3030 pass. `check_conventions.py --base upstream/main` passes. `pr_overlap.py` reports no overlap with open pull requests. - Not tested: Windows, a title. ### 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-10-31 00:12:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T00:12:52Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The null-buffer test and implementation assert a std::invalid_argument behavior that the cited Abseil revisions do not specify; their FastIntToBuffer(int32_t, ...) takes a non-null pointer and writes through it.

What I ran

Reviewed head 314a8c5b492c364f6ce9d520e78dde41c2fa2a91 on PR base 0269d841bbc14b8c92a59b47aca4e18d3149596b. The merge preview against current main 7ceda1326c82e86252d161fa12eef47498eb417d was clean; the five commits since the prior preview touch unrelated exports and debt files. Environment: Linux 6.1.0-54-amd64, x86_64; Python 3.11.2. I did not build or compile the C++ target.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13687
python3 tools/pr_abi_audit.py --base 0269d841bbc14b8c92a59b47aca4e18d3149596b --head 314a8c5b492c364f6ce9d520e78dde41c2fa2a91 --json
python3 tools/pr_test_quality.py --root /tmp/AnyPS5-pr13687-review --json core/libs/prx/libwebrtc/tests/FastIntToBuffer.cpp core/libs/prx/libwebrtc/CMakeLists.txt

Results

Check Result
git diff --check and conventions/template Passed.
Current-main merge preview Clean at 7ceda1326c82e86252d161fa12eef47498eb417d; intervening main commits changed unrelated export/debt files.
Export ABI audit The target symbol has a declaration and definition and no symbol-specific finding; overall audit status was passed_with_warnings. This lexical audit does not verify the compiled ABI. The precheck snapshot lacked this workspace helper, so I ran it separately from the workspace.
Test registration CMake explicitly builds the new test executable and registers guest_webrtc_fast_int_to_buffer. The quality heuristic's possible-unregistered warning is a false positive for this CMAKE_CURRENT_SOURCE_DIR path; the precheck snapshot lacked the workspace helper, so I ran it separately.
Exact-head C++ tests Not run locally because this initial review does not build. The author reports 3030/3030 CTest tests passing on the head; that run was not independently reproduced.
Hosted CI Conventions, intake, eligibility, labels, library-portability, report and Windows jobs passed. Linux and relinker jobs were skipped.
Relevant unedited tool output
All conventions checks passed.
{
  "name": "_ZN4absl16numbers_internal15FastIntToBufferEiPc_nid_postfix",
  "computed_nid": "+g8fWHAUVNQ",
  "declarations": [
    "core/libs/prx/libwebrtc/include/Api.hpp"
  ],
  "definitions": [
    "core/libs/prx/libwebrtc/Export.cpp"
  ],
  "explicit_aliases": [],
  "version": "not encoded by these source declarations; not verified"
}
{
  "findings": [
    {
      "path": "core/libs/prx/libwebrtc/tests/FastIntToBuffer.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}

Negative control

Assertion Mutation Result
Null buffer throws std::invalid_argument None; the exact-head C++ test binary was not available without a build Not run.

Findings

Blocking

Export.cpp explicitly throws std::invalid_argument for a null buffer, and TestNullBuffer requires that exception. Both cited Abseil revisions annotate this parameter as absl::Nonnull<char*> and write through it without a null check. That establishes a non-null precondition, not a C++ exception contract for null. The PR body also says the reference “throws,” which is not supported by those sources. Please remove the null-specific conformance assertion and either remove the guard or document it as a deliberate host-side defensive behavior rather than console parity. If null is a supported console input with this exception result, provide evidence for that behavior.

Non-blocking

The quality heuristic did not recognize the test registration, but the new CMakeLists.txt explicitly adds the executable and CTest entry. I found no separate blocker in the valid-input conversion path by source inspection; it has not been compiled or run in this review.

Sources

Not verified

I did not run the C++ tests, build the library, test Windows/macOS behavior, or verify behavior on a PS5. The author-reported full CTest run is not an independent result from this review.

To get this to a good state

Please remove or qualify the unsupported null-buffer behavior and update the test/body accordingly. I will rerun the same review checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5720024684 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13687#pullrequestreview-5720024684). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T00:12:52Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The null-buffer test and implementation assert a `std::invalid_argument` behavior that the cited Abseil revisions do not specify; their `FastIntToBuffer(int32_t, ...)` takes a non-null pointer and writes through it. ## What I ran Reviewed head `314a8c5b492c364f6ce9d520e78dde41c2fa2a91` on PR base `0269d841bbc14b8c92a59b47aca4e18d3149596b`. The merge preview against current `main` `7ceda1326c82e86252d161fa12eef47498eb417d` was clean; the five commits since the prior preview touch unrelated exports and debt files. Environment: Linux 6.1.0-54-amd64, x86_64; Python 3.11.2. I did not build or compile the C++ target. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13687 python3 tools/pr_abi_audit.py --base 0269d841bbc14b8c92a59b47aca4e18d3149596b --head 314a8c5b492c364f6ce9d520e78dde41c2fa2a91 --json python3 tools/pr_test_quality.py --root /tmp/AnyPS5-pr13687-review --json core/libs/prx/libwebrtc/tests/FastIntToBuffer.cpp core/libs/prx/libwebrtc/CMakeLists.txt ``` ## Results | Check | Result | |---|---| | `git diff --check` and conventions/template | Passed. | | Current-main merge preview | Clean at `7ceda1326c82e86252d161fa12eef47498eb417d`; intervening `main` commits changed unrelated export/debt files. | | Export ABI audit | The target symbol has a declaration and definition and no symbol-specific finding; overall audit status was `passed_with_warnings`. This lexical audit does not verify the compiled ABI. The precheck snapshot lacked this workspace helper, so I ran it separately from the workspace. | | Test registration | CMake explicitly builds the new test executable and registers `guest_webrtc_fast_int_to_buffer`. The quality heuristic's possible-unregistered warning is a false positive for this `CMAKE_CURRENT_SOURCE_DIR` path; the precheck snapshot lacked the workspace helper, so I ran it separately. | | Exact-head C++ tests | Not run locally because this initial review does not build. The author reports 3030/3030 CTest tests passing on the head; that run was not independently reproduced. | | Hosted CI | Conventions, intake, eligibility, labels, library-portability, report and Windows jobs passed. Linux and relinker jobs were skipped. | <details><summary>Relevant unedited tool output</summary> ```text All conventions checks passed. ``` ```json { "name": "_ZN4absl16numbers_internal15FastIntToBufferEiPc_nid_postfix", "computed_nid": "+g8fWHAUVNQ", "declarations": [ "core/libs/prx/libwebrtc/include/Api.hpp" ], "definitions": [ "core/libs/prx/libwebrtc/Export.cpp" ], "explicit_aliases": [], "version": "not encoded by these source declarations; not verified" } ``` ```json { "findings": [ { "path": "core/libs/prx/libwebrtc/tests/FastIntToBuffer.cpp", "line": 1, "kind": "possible-unregistered-cpp-test", "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage." } ], "negative_control_candidates": [], "limits": [ "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.", "A test that passes against base is not by itself proof that the PR test is inadequate.", "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error." ] } ``` </details> ## Negative control | Assertion | Mutation | Result | |---|---|---| | Null buffer throws `std::invalid_argument` | None; the exact-head C++ test binary was not available without a build | Not run. | ## Findings ### Blocking `Export.cpp` explicitly throws `std::invalid_argument` for a null buffer, and `TestNullBuffer` requires that exception. Both cited Abseil revisions annotate this parameter as `absl::Nonnull<char*>` and write through it without a null check. That establishes a non-null precondition, not a C++ exception contract for null. The PR body also says the reference “throws,” which is not supported by those sources. Please remove the null-specific conformance assertion and either remove the guard or document it as a deliberate host-side defensive behavior rather than console parity. If null is a supported console input with this exception result, provide evidence for that behavior. ### Non-blocking The quality heuristic did not recognize the test registration, but the new `CMakeLists.txt` explicitly adds the executable and CTest entry. I found no separate blocker in the valid-input conversion path by source inspection; it has not been compiled or run in this review. ## Sources - [Abseil implementation at Chromium pin `65ef38d`](https://chromium.googlesource.com/chromium/src/third_party/+/65ef38d36813d1ad9d4cbf8a18b32ac3691f418b/abseil-cpp/absl/strings/numbers.cc#L302-L314) - [Abseil implementation at Chromium pin `d212a71`](https://chromium.googlesource.com/chromium/src/third_party/+/d212a71416ad7c6ceca04d6d27dfdd84fd00c04c/abseil-cpp/absl/strings/numbers.cc#L303-L315) - [PR implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/314a8c5b492c364f6ce9d520e78dde41c2fa2a91/core/libs/prx/libwebrtc/Export.cpp#L46-L58) - [Null-buffer assertion at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/314a8c5b492c364f6ce9d520e78dde41c2fa2a91/core/libs/prx/libwebrtc/tests/FastIntToBuffer.cpp#L54-L63) ## Not verified I did not run the C++ tests, build the library, test Windows/macOS behavior, or verify behavior on a PS5. The author-reported full CTest run is not an independent result from this review. ## To get this to a good state Please remove or qualify the unsupported null-buffer behavior and update the test/body accordingly. I will rerun the same review checks on the updated head.
MarcZX10 commented 2026-10-31 00:23:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T00:23:54Z.

Review: APPROVED


Re-checked — looks good

Correction on unchanged head 314a8c5b492c364f6ce9d520e78dde41c2fa2a91: my prior blocking finding treated a null buffer as supported input, but the pinned Abseil signature requires absl::Nonnull<char*>; the implementation's defensive std::invalid_argument check is outside that contract and is not a blocker. The PR text should describe the exception as local defensive behavior rather than upstream behavior.

Sources

Not verified

I did not rerun local tests or a build for this correction; the PR head is unchanged, and the previous same-head review recorded the checks and author-reported test results.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5720079679 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13687#pullrequestreview-5720079679). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T00:23:54Z. **Review:** APPROVED --- # Re-checked — looks good Correction on unchanged head `314a8c5b492c364f6ce9d520e78dde41c2fa2a91`: my prior blocking finding treated a null buffer as supported input, but the pinned Abseil signature requires `absl::Nonnull<char*>`; the implementation's defensive `std::invalid_argument` check is outside that contract and is not a blocker. The PR text should describe the exception as local defensive behavior rather than upstream behavior. ## Sources - [Pinned Abseil declaration and implementation](https://chromium.googlesource.com/chromium/src/third_party/+/65ef38d36813d1ad9d4cbf8a18b32ac3691f418b/abseil-cpp/absl/strings/numbers.cc) ## Not verified I did not rerun local tests or a build for this correction; the PR head is unchanged, and the previous same-head review recorded the checks and author-reported test results.
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!13687
No description provided.