Skip to content
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

BeginConnect_EndPoint_AddressFamily_Throws_NotSupported test fails deterministically on netfx on RS4 #26062

Closed
Tracked by #93172 ...
stephentoub opened this issue May 3, 2018 · 7 comments · Fixed by dotnet/corefx#29484
Labels
area-System.Net.Sockets test-run-desktop Test failures in .NET Framework "Desktop" test runs (running CoreFX test assets)
Milestone

Comments

@stephentoub
Copy link
Member

System.Net.Sockets.Tests.ArgumentValidation.BeginConnect_EndPoint_AddressFamily_Throws_NotSupported [FAIL]
        Assert.Throws() Failure
        Expected: typeof(System.NotSupportedException)
        Actual:   typeof(System.InvalidOperationException): BeginConnect cannot be called while another asynchronous operation is in progress on the same Socket.
        Stack Trace:
             at System.Net.Sockets.Socket.BeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state)
             at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1](Func`4 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, Object state, TaskCreationOptions cr
  eationOptions)
             at System.Net.Sockets.SocketTaskExtensions.ConnectAsync(Socket socket, EndPoint remoteEndPoint)
             at System.Net.Sockets.Tests.ArgumentValidation.<>c.<BeginConnect_EndPoint_AddressFamily_Throws_NotSupported>b__106_1()
@davidsh
Copy link
Contributor

davidsh commented May 3, 2018

RS4 (Windows 10 April 2018 Update) contains .NET Framework 4.7.2. There was an explicit bug fix for 4.7.2 that made this exception happen when concurrent I/O (a form of misuse) happens with those APIs.

@stephentoub
Copy link
Member Author

There's no concurrent use in this test. Seems like the fix may have been broken.

@davidsh
Copy link
Contributor

davidsh commented May 3, 2018

See internal bug: 188428

cc: @Caesar1995

@davidsh
Copy link
Contributor

davidsh commented May 3, 2018

From: https://github.com/Microsoft/dotnet/blob/master/releases/net472/dotnet472-changes.md#networking

Socket.BeginConnect will now consistently throw InvalidOperationException when attempting multiple operations. [188428, System.dll, Bug]

@stephentoub
Copy link
Member Author

From looking at the decompiled source, I see this:

if (Interlocked.Exchange(ref this.asyncConnectOperationLock, 1) != 0)
    throw new InvalidOperationException(SR.GetString("net_sockets_no_duplicate_async"));

and then after that it does things like:

if ((point.AddressFamily != AddressFamily.Unspecified) && !this.CanTryAddressFamily(point.AddressFamily))
    throw new NotSupportedException(SR.GetString("net_invalidversion"));

That means we're leaving asyncConnectOperationLock set to 1 when something fails after it, and the socket becomes unusable for any subsequent attempt at a connect. That seems wrong, and we should be resetting asyncConnectOperationLock in such cases.

@davidsh
Copy link
Contributor

davidsh commented May 3, 2018

cc: @karelz

@stephentoub
Copy link
Member Author

In any event, I'll fix up the test to not depend on this.

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 3.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Sockets test-run-desktop Test failures in .NET Framework "Desktop" test runs (running CoreFX test assets)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants