-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DualModeAcceptAsync.AcceptAsyncV6BoundToAnyV4_CantConnect failed in CI #19162
Comments
I will disable the test for now. |
Fix is to disable such tests on non-Windows. Loopback IPV4 and Loopback IPV6 considered separate addresses and on Linux it is easy to get both to exist as separate connections with same port. |
Test
Build: -20190815(Master) |
Failed again on |
FWIW I dug up my old POSIX repro that shows port collisions are possible across protocols; this should only repro on Unix although with enough iterations to cycle around past 65,535 could also occur on Windows (haven't verified). It asks for a port using Ipv6 and then loops 10,000 times to see if the same port number can be assigned for Ipv4. Not tested here but you can have both UDP vs TCP on same protocol (IPV4) using the same port, meaning collisions are possible that way too. #include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/socket.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
static int CreateIpv4Socket(bool closeSocket, int portToUse)
{
struct sockaddr_in serv_addr;
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
{
perror("ERROR opening socket");
exit(1);
}
bzero((char *)&serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
if (portToUse == 0)
{
serv_addr.sin_port = 0;
}
else
{
serv_addr.sin_port = htons(portToUse);
}
if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
perror("ERROR on binding");
exit(1);
}
struct sockaddr_in out_addr;
socklen_t len = sizeof(out_addr);
if (getsockname(sockfd, (struct sockaddr *)&out_addr, &len) == -1) {
perror("getsockname");
exit(1);
}
int portUsed = out_addr.sin_port;
if (closeSocket)
close(sockfd);
return portUsed;
}
static int CreateIpv6Socket(bool closeSocket, int portToUse)
{
struct sockaddr_in6 serv_addr;
int sockfd = socket(AF_INET6, SOCK_STREAM, 0);
if (sockfd < 0)
{
perror("ERROR opening socket2");
exit(1);
}
bzero((char *)&serv_addr, sizeof(serv_addr));
serv_addr.sin6_family = AF_INET6;
serv_addr.sin6_addr = in6addr_loopback;
if (portToUse == 0)
{
serv_addr.sin6_port = 0;
}
else
{
serv_addr.sin6_port = htons(portToUse);
}
if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
{
perror("ERROR on binding2");
exit(1);
}
struct sockaddr_in6 addr_in6;
socklen_t len2 = sizeof(addr_in6);
if (getsockname(sockfd, (struct sockaddr *)&addr_in6, &len2) == -1)
{
perror("getsockname2");
exit(1);
}
int portUsed = addr_in6.sin6_port;
if (closeSocket)
close(sockfd);
return portUsed;
}
int main(int argc, char *argv[])
{
int port = CreateIpv6Socket(false, 0);
for (int i = 0; i < 10000; i++)
{
int port2 = CreateIpv4Socket(true, 0);
printf("count: %d\tport number %d\t; original:%d\n", i, ntohs(port2), ntohs(port));
if (port == port2)
{
perror("DUPLICATE SOCKET. STOPPING");
exit(1);
}
}
return 0;
} |
No recent Windows failures, stabilization & re-enabling is covered by #1481. |
https://ci.dot.net/job/dotnet_corefx/job/master/job/ubuntu14.04_release_prtest/2476/consoleText
The text was updated successfully, but these errors were encountered: