diff --git a/src/pkg/syscall/syscall_bsd.go b/src/pkg/syscall/syscall_bsd.go index c1a822aa17..1d873b69ac 100644 --- a/src/pkg/syscall/syscall_bsd.go +++ b/src/pkg/syscall/syscall_bsd.go @@ -304,6 +304,14 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) { if err != nil { return } + if len == 0 { + // Accepted socket has no address. + // This is likely due to a bug in xnu kernels, + // where instead of ECONNABORTED error socket + // is accepted, but has no address. + Close(nfd) + return 0, nil, ECONNABORTED + } sa, err = anyToSockaddr(&rsa) if err != nil { Close(nfd)