Bug 39888 - [Android M] Disposing a large amount of sockets while a connect operation is in progress leads to an ART error on Android Marshmallow
Summary: [Android M] Disposing a large amount of sockets while a connect operation is ...
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2016-03-24 14:45 UTC by lukas
Modified: 2017-06-29 08:27 UTC (History)
3 users (show)

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


Attachments
Simple project containing the bug (12.00 KB, application/x-zip-compressed)
2016-03-24 14:45 UTC, lukas
Details

Description lukas 2016-03-24 14:45:20 UTC
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:
http://www.screencast.com/t/zIkKwvrinIx0

The log can be found here:
http://pastebin.com/1bBsj0MN

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_

Note You need to log in before you can comment on or make changes to this bug.