Repository navigation
fix(network): bind ENet control socket on IPv6 wildcard without IPv6 address - #6164
Conversation
|
|
Thanks for the focused fix and the same-host streaming check. Two small follow-ups on
if (!host) {
BOOST_LOG(error) << "Failed to create ENet host on ["sv << bind_addr << "]:"sv << port;
return host;
}
These are source-review suggestions; I did not run the platform tests. Review completed by Codex | Model: unavailable | Thinking: unavailable |
|
I hit the same crash in |
…address With address_family = both, the ENet control server binds "::". ENet's enet_address_set_host() resolves it through getaddrinfo() with AI_ADDRCONFIG, which fails on hosts without a non-loopback IPv6 address. The failure was ignored, so bind() received an empty address and returned EINVAL; host_create() then dereferenced the null host and Sunshine crashed as soon as a client started a stream. Convert numeric bind addresses directly through a Boost.Asio endpoint, only resolve host names through ENet, and return an empty handle with an error log when resolving or binding fails. Fixes SunshineStream#6161 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
errno may be stale or unrelated when enet_host_create() returns null, and Windows socket failures use Winsock errors that ENet may clear during cleanup. Log only the address and port, and remove the unused <cerrno> and <cstring> includes. Also use the sockaddr_as copy helper in HostCreateBindsAvailablePort to avoid reading sockaddr_storage through a reinterpret_cast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5da3b0a to
25607fa
Compare
Bundle ReportChanges will increase total bundle size by 1.5kB (0.15%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: sunshine-esmAssets Changed:
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6164 +/- ##
==========================================
+ Coverage 51.85% 51.93% +0.08%
==========================================
Files 150 150
Lines 32848 32863 +15
Branches 13858 13862 +4
==========================================
+ Hits 17032 17068 +36
- Misses 12277 12820 +543
+ Partials 3539 2975 -564
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 24 files with indirect coverage changes Continue to review full report in Codecov by Harness.
|
Screenshot ComparisonPR #6164 screenshots vs Matrix:
|























































































Description
Sunshine crashes with SIGSEGV as soon as a Moonlight client starts a stream when
address_family = bothis configured on a host that has no non-loopback IPv6 address.Cause
address_family = both,net::host_create()binds the ENet control server to::.enet_address_set_host(), which resolves throughgetaddrinfo()withAI_ADDRCONFIG. That flag makesgetaddrinfo("::")fail withEAI_ADDRFAMILYwhen the host has no non-loopback IPv6 address.ENetAddressstayed empty (ss_family = 0, length 0),enet_address_set_port()did nothing, andbind()failed withEINVAL.enet_host_create()then returned null, andhost_create()dereferenced it inenet_socket_set_option(host->socket, ...).RTSP and the HTTP servers bind
::through Boost.Asio, which does not useAI_ADDRCONFIG, so pairing and the initial connection work. Only the ENet control socket fails.Changes
net::set_enet_address(). It converts numeric IPv4/IPv6 addresses directly through a Boost.Asio endpoint andenet_address_set_address(), and resolves only host names through ENet.host_create()now returns an empty handle and logs an error when resolving the bind address fails, or whenenet_host_create()fails (withstrerror(errno)), instead of dereferencing null. The existing caller already handles an empty handle with "Couldn't bind Control server".Screenshot
Issues Fixed or Closed
Roadmap Issues
Testing
Added tests in
tests/unit/test_network.cpp:SetEnetAddressTest.ConvertsIpv6Wildcard,ConvertsIpv4Address,ResolvesHostName,RejectsUnresolvableHostNameBindAddressTest.HostCreateBindsAvailablePortBindAddressTest.HostCreateBindsIpv6Wildcard(skips if IPv6 sockets are unavailable)BindAddressTest.HostCreateReturnsEmptyHandleWhenPortIsInUseBindAddressTest.HostCreateReturnsEmptyHandleForUnresolvableAddressResults on CachyOS (GCC 16.2.1, Debug, no global IPv6 address configured):
host_create(),HostCreateReturnsEmptyHandleWhenPortIsInUse,HostCreateBindsIpv6WildcardandHostCreateReturnsEmptyHandleForUnresolvableAddresseach crash with SIGSEGV (exit 139). With the fix, they pass.test_sunshinesuite: 971 passed, 7 skipped, 0 failed.uv run --locked lb-update-clang-formatmade no changes.Manual validation on the same host (AMD RX 9070 XT, KDE Wayland, portal capture):
address_family = both, the log showedFailed to create ENet host on [::]:47999: Invalid argument; without the null check, Sunshine crashed with SIGSEGV innet::host_create(src/network.cpp).address_family = both.Not run: Windows, macOS and FreeBSD builds.
Type of Change
Checklist
AI Usage
See our AI usage policy.
Claude Code debugged the crash from the core dump and runtime logs, implemented the fix and tests, and prepared this PR. The fix was validated manually with a real Moonlight client.
🤖 Generated with Claude Code