test(libwebrtc): zero the address unions in the NetworkManager test #26729

Merged
Romannachwievor merged 3 commits from upstream-pr/26729 into main 2026-11-25 02:12:43 +00:00
Romannachwievor commented 2026-11-24 17:38:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Romannachwievor on 2026-11-24T17:38:25Z.


What

guest_webrtc_network_manager fails on macOS since #24668 added it:

libwebrtc NetworkManager check failed at line 109

The test helper Ipv6() built its address with WebRtcInterfaceAddress ip{&ipVTable, WebRtcAfInet6, {}, flags}. For a union, {} is aggregate initialization of the first member only, which is the four-byte ip4. Bytes 4 to 14 of ip6 were never set, and IPAddress::operator== compares all 16 bytes with memcmp (IpAddress.cpp:92). With AppleClang those bytes held leftover stack data, so GetNetworkFromAddress did not match fc00::4 against the same address in the second network and returned null. GCC happened to leave zeros there, which is why Linux CI passes.

The helper now initializes the ip6 member ({.ip6 = {}}), so all 16 bytes start at zero. The other addresses in the file (Ipv4(), result, nil) had the same indeterminate tail and get the same initializer, although nothing reads those bytes today. A new lookup differs from a stored address only in byte 8 and must miss, so a comparison that skips part of the 16 bytes now fails the test. Only the test changes; the libwebrtc sources do not build addresses this way.

Overlap: pr_overlap.py --names finds no open PR that changes GetNetworkFromAddress or IPAddress::operator==, and pr_overlap.py --branch reports no overlap with open pull requests.

Tested

Apple M1, macOS 26.5, x86_64 build under Rosetta, AppleClang 21, Release.

  • main at adacf0bd83: fails 3 of 3 serial runs at line 109 (it also fails in a full CPU run with ctest -j6). At 23562e14f9 with the test file from main: fails 2 of 2 at line 109.
  • This branch at b71fb484b6 (on 23562e14f9): passes 3 of 3.
  • Mutation: IPAddress::operator== comparing only 8 of the 16 IPv6 bytes fails at line 111, the new byte-8 lookup.
  • python3 tools/check_conventions.py --base origin/main: passed.
  • After merging current main (920773c7c7) the test could not be rebuilt on macOS: libc no longer compiles there since #10416 (Runtime.cpp:296, no member __contained_virtual_mask in __cxxabiv1::__class_type_info). #26739 fixes that build. With #26739 merged locally on top of this branch, the test passes 3 of 3. The merge does not touch this test file.

Not run: Linux and Windows (CI covers them).

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 (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5477256635 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26729). Originally posted by [Romannachwievor](https://github.com/Romannachwievor) on 2026-11-24T17:38:25Z. --- ### What `guest_webrtc_network_manager` fails on macOS since #24668 added it: ``` libwebrtc NetworkManager check failed at line 109 ``` The test helper `Ipv6()` built its address with `WebRtcInterfaceAddress ip{&ipVTable, WebRtcAfInet6, {}, flags}`. For a union, `{}` is aggregate initialization of the first member only, which is the four-byte `ip4`. Bytes 4 to 14 of `ip6` were never set, and `IPAddress::operator==` compares all 16 bytes with `memcmp` (`IpAddress.cpp:92`). With AppleClang those bytes held leftover stack data, so `GetNetworkFromAddress` did not match `fc00::4` against the same address in the second network and returned null. GCC happened to leave zeros there, which is why Linux CI passes. The helper now initializes the `ip6` member (`{.ip6 = {}}`), so all 16 bytes start at zero. The other addresses in the file (`Ipv4()`, `result`, `nil`) had the same indeterminate tail and get the same initializer, although nothing reads those bytes today. A new lookup differs from a stored address only in byte 8 and must miss, so a comparison that skips part of the 16 bytes now fails the test. Only the test changes; the libwebrtc sources do not build addresses this way. Overlap: `pr_overlap.py --names` finds no open PR that changes `GetNetworkFromAddress` or `IPAddress::operator==`, and `pr_overlap.py --branch` reports no overlap with open pull requests. ### Tested Apple M1, macOS 26.5, x86_64 build under Rosetta, AppleClang 21, Release. - `main` at adacf0bd83: fails 3 of 3 serial runs at line 109 (it also fails in a full CPU run with `ctest -j6`). At 23562e14f9 with the test file from `main`: fails 2 of 2 at line 109. - This branch at b71fb484b6 (on 23562e14f9): passes 3 of 3. - Mutation: `IPAddress::operator==` comparing only 8 of the 16 IPv6 bytes fails at line 111, the new byte-8 lookup. - `python3 tools/check_conventions.py --base origin/main`: passed. - After merging current `main` (920773c7c7) the test could not be rebuilt on macOS: `libc` no longer compiles there since #10416 (`Runtime.cpp:296`, no member `__contained_virtual_mask` in `__cxxabiv1::__class_type_info`). #26739 fixes that build. With #26739 merged locally on top of this branch, the test passes 3 of 3. The merge does not touch this test file. Not run: Linux and Windows (CI covers them). ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
kripotker commented 2026-11-24 19:36:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kripotker on 2026-11-24T19:36:13Z.

Review: APPROVED


Review: test(libwebrtc): zero the address unions in the NetworkManager test

Approve.

What I checked

  • The cause is correct. WebRtcIpAddress::address is a union whose first member is the 4-byte ip4 (core/libs/prx/libwebrtc/include/IpAddress.hpp:21-24). Aggregate initialization from {} initializes only the first member of a union, so bytes 4-15 of ip6 were indeterminate. IPAddress::operator== compares all 16 bytes for WebRtcAfInet6 (src/IpAddress.cpp:100), so a stray non-zero byte makes GetNetworkFromAddress miss.
  • The fix is correct. {.ip6 = {}} value-initializes the whole 16-byte member. Designated initializers are already available, because this file uses C++20 (std::source_location).
  • Scope. Only the test file changes, and every address built in it now uses the same initializer.
  • Sabotage check: a test-only change; nothing new is run.

Non-blocking note: the mutation claim in the description

The description says an operator== that compares only 8 of the 16 bytes "fails at line 111, the new byte-8 lookup". On this branch, line 111 is the existing missing assertion, and the new byte-8 lookup is line 114. I made that mutation (memcmp(..., 8) for IPv6):

Test file Result with the 8-byte compare
this PR's fails at line 111
main's fails at line 111

So the existing missing check already catches that mutation. The new byte-8 lookup only adds coverage for a compare that skips byte 8 itself, which is still worth having.

What I ran

Windows 11, MSYS2 UCRT64 GCC 16.2.0, Release/Ninja, BUILD_TESTING=ON, with PR head 920773c7c7's tests/NetworkManager.cpp in a built tree. The change is test-only, so the libwebrtc sources there are unchanged from main.

  • ctest -R '^guest_webrtc_network_manager$' passes.
  • The mutation above, run with both test files.

GCC doesn't reproduce the AppleClang failure, so I couldn't show the original failure on this machine.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6046039405 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26729#pullrequestreview-6046039405). Originally posted by [kripotker](https://github.com/kripotker) on 2026-11-24T19:36:13Z. **Review:** APPROVED --- ## Review: test(libwebrtc): zero the address unions in the NetworkManager test **Approve.** ### What I checked - **The cause is correct.** `WebRtcIpAddress::address` is a union whose first member is the 4-byte `ip4` (`core/libs/prx/libwebrtc/include/IpAddress.hpp:21-24`). Aggregate initialization from `{}` initializes only the first member of a union, so bytes 4-15 of `ip6` were indeterminate. `IPAddress::operator==` compares all 16 bytes for `WebRtcAfInet6` (`src/IpAddress.cpp:100`), so a stray non-zero byte makes `GetNetworkFromAddress` miss. - **The fix is correct.** `{.ip6 = {}}` value-initializes the whole 16-byte member. Designated initializers are already available, because this file uses C++20 (`std::source_location`). - **Scope.** Only the test file changes, and every address built in it now uses the same initializer. - **Sabotage check:** a test-only change; nothing new is run. ### Non-blocking note: the mutation claim in the description The description says an `operator==` that compares only 8 of the 16 bytes "fails at line 111, the new byte-8 lookup". On this branch, line 111 is the existing `missing` assertion, and the new byte-8 lookup is line 114. I made that mutation (`memcmp(..., 8)` for IPv6): | Test file | Result with the 8-byte compare | |---|---| | this PR's | fails at line 111 | | `main`'s | fails at line 111 | So the existing `missing` check already catches that mutation. The new byte-8 lookup only adds coverage for a compare that skips byte 8 itself, which is still worth having. ### What I ran Windows 11, MSYS2 UCRT64 GCC 16.2.0, Release/Ninja, `BUILD_TESTING=ON`, with PR head 920773c7c7's `tests/NetworkManager.cpp` in a built tree. The change is test-only, so the libwebrtc sources there are unchanged from `main`. - `ctest -R '^guest_webrtc_network_manager$'` passes. - The mutation above, run with both test files. GCC doesn't reproduce the AppleClang failure, so I couldn't show the original failure on this machine. AI-assisted: yes (Claude Code).
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!26729
No description provided.