Bug 60772 - Socket crashes on connect error
Summary: Socket crashes on connect error
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 5.4 (2017-06)
Hardware: PC All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-11-20 13:47 UTC by alexander.pertsovsky@gmail.com
Modified: 2018-01-05 22:35 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 60772 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description alexander.pertsovsky@gmail.com 2017-11-20 13:47:20 UTC
I'm using Visual studio for mac with mono 5.4 to run a mac app.
We're using websocket4net.
After we upgraded to mono 5.4 our app began to crash randomly.
The reason of a crash is in new System.Net.Sockets implementation - it crashes on connection error processing.

My stack trace is 
System.NotImplementedException: The method or operation is not implemented.
  at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationAsyncFailure (System.Exception exception, System.Int32 bytesTransferred, System.Net.Sockets.SocketFlags flags) [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs:257 
  at System.Net.Sockets.MultipleConnectAsync.AsyncFail (System.Exception e) [0x0001a] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs:305 
  at System.Net.Sockets.MultipleConnectAsync.InternalConnectCallback (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs args) [0x000b7] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs:212 
  at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted (System.Net.Sockets.SocketAsyncEventArgs e) [0x0000e] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs:210 
  at System.Net.Sockets.SocketAsyncEventArgs.Complete () [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs:200 
  at System.Net.Sockets.Socket+<>c.<.cctor>b__307_3 (System.IAsyncResult ares) [0x00057] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/System/System.Net.Sockets/Socket.cs:946 
  at System.Net.Sockets.SocketAsyncResult+<>c.<Complete>b__27_0 (System.Object state) [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/System/System.Net.Sockets/SocketAsyncResult.cs:157 
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00015] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1279 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:856 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1211 

Reason of the crash is 

From https://github.com/mono/mono/blob/master/mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs
		internal void FinishConnectByNameSyncFailure (Exception exception, int bytesTransferred, SocketFlags flags)
		{
			throw new NotImplementedException ();
		}

		internal void FinishOperationAsyncFailure (Exception exception, int bytesTransferred, SocketFlags flags)
		{
			throw new NotImplementedException ();
		}


For our app it is a real show stopper.

Also reproduced when just removing network cable.
Comment 1 alexander.pertsovsky@gmail.com 2017-11-20 13:49:46 UTC
Another stacktrace (when I removed network cable and my app tried to reconnect)

Another stacktrace
 The method or operation is not implemented. |
System.NotImplementedException: The method or operation is not implemented.
  at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationAsyncFailure (System.Exception exception, System.Int32 bytesTransferred, System.Net.Sockets.SocketFlags flags) [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/System/System.Net.Sockets/SocketAsyncEventArgs.cs:257
  at System.Net.Sockets.MultipleConnectAsync.AsyncFail (System.Exception e) [0x0001a] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs:305
  at System.Net.Sockets.MultipleConnectAsync.Fail (System.Boolean sync, System.Exception e) [0x0000c] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs:273
  at System.Net.Sockets.MultipleConnectAsync.DoDnsCallback (System.IAsyncResult result, System.Boolean sync) [0x000b4] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs:133
  at System.Net.Sockets.MultipleConnectAsync.DnsCallback (System.IAsyncResult result) [0x00008] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs:78
  at (wrapper managed-to-native) System.Runtime.Remoting.Messaging.AsyncResult:Invoke (System.Runtime.Remoting.Messaging.AsyncResult)
  at System.Runtime.Remoting.Messaging.AsyncResult.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Runtime.Remoting.Messaging/AsyncResult.cs:210
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:856
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1211
Comment 2 Miguel de Icaza [MSFT] 2018-01-05 22:35:08 UTC
See bug report here:

https://github.com/mono/mono/issues/6428

With a potential pull request there.