Created attachment 15517 [details]
Simple project containing the bug
I made an app which needs to scan networks for specific hosts. More precisely I want to create a list of all hosts with whom the connection was successfully established on a specific port.
e.g. find all reachable hosts from 192.168.0.1 to 192.168.0.255 on port 80
The standard timeout for a connect operation is roughly 2 minutes and definitely too high for my purpose. Therefore I had to find a way to set a timeout. The only intended way to do this is by using the static CancelConnectAsync method of the Socket class. See https://msdn.microsoft.com/library/system.net.sockets.socket.cancelconnectasync(v=vs.110).aspx
Xamarin Android however does not support this method. My workaround for this is to forcefully stop the ongoing connect by closing the socket. So far it worked really well. On Android Marshmallow however the app crashes after doing so by no later than 255 times.
I attached a simple test case and created a video of it here:
The log can be found here:
This is probably the most important line.
03-24 10:17:54.031: A/art(1604): art/runtime/fault_handler.cc:117] Check failed: !initialized_