Repository navigation
Conversation
…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>
Author
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Member
|
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 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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