test(libwebrtc): zero the address unions in the NetworkManager test #26729
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26729"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Romannachwievor on 2026-11-24T17:38:25Z.
What
guest_webrtc_network_managerfails on macOS since #24668 added it:The test helper
Ipv6()built its address withWebRtcInterfaceAddress ip{&ipVTable, WebRtcAfInet6, {}, flags}. For a union,{}is aggregate initialization of the first member only, which is the four-byteip4. Bytes 4 to 14 ofip6were never set, andIPAddress::operator==compares all 16 bytes withmemcmp(IpAddress.cpp:92). With AppleClang those bytes held leftover stack data, soGetNetworkFromAddressdid not matchfc00::4against 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
ip6member ({.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 --namesfinds no open PR that changesGetNetworkFromAddressorIPAddress::operator==, andpr_overlap.py --branchreports no overlap with open pull requests.Tested
Apple M1, macOS 26.5, x86_64 build under Rosetta, AppleClang 21, Release.
mainatadacf0bd83: fails 3 of 3 serial runs at line 109 (it also fails in a full CPU run withctest -j6). At23562e14f9with the test file frommain: fails 2 of 2 at line 109.b71fb484b6(on23562e14f9): passes 3 of 3.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.main(920773c7c7) the test could not be rebuilt on macOS:libcno longer compiles there since #10416 (Runtime.cpp:296, no member__contained_virtual_maskin__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
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)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
WebRtcIpAddress::addressis a union whose first member is the 4-byteip4(core/libs/prx/libwebrtc/include/IpAddress.hpp:21-24). Aggregate initialization from{}initializes only the first member of a union, so bytes 4-15 ofip6were indeterminate.IPAddress::operator==compares all 16 bytes forWebRtcAfInet6(src/IpAddress.cpp:100), so a stray non-zero byte makesGetNetworkFromAddressmiss.{.ip6 = {}}value-initializes the whole 16-byte member. Designated initializers are already available, because this file uses C++20 (std::source_location).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 existingmissingassertion, and the new byte-8 lookup is line 114. I made that mutation (memcmp(..., 8)for IPv6):main'sSo the existing
missingcheck 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'stests/NetworkManager.cppin a built tree. The change is test-only, so the libwebrtc sources there are unchanged frommain.ctest -R '^guest_webrtc_network_manager$'passes.GCC doesn't reproduce the AppleClang failure, so I couldn't show the original failure on this machine.
AI-assisted: yes (Claude Code).