Bug 53262 - AndroidClientHandler multithreading issue
Summary: AndroidClientHandler multithreading issue
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 7.1 (C9)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Habersack
URL:
Depends on:
Blocks:
 
Reported: 2017-03-11 17:04 UTC by Hrvoje
Modified: 2017-03-15 21:32 UTC (History)
1 user (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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Hrvoje 2017-03-11 17:04:45 UTC
I believe there is a multithreading problem in AndroidClientHandler.
Everything works when I switch to ManagedHttpHandler.

If you run two different two http requests you get into issue that raises that exception.
Try to create two requests, one that lasts longer than two seconds, and immediately after it starts, run second request, that finishes quickly.
Note, that both requests are runned inside different threads using:

Task.Run(() => {
        // run task here
}, LongRunning);


Here is exception from the LogCat:
03-11 17:29:05.920	Samsung GT-I9305	Error	10804	Orderion.App	--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.
03-11 17:29:05.920	Samsung GT-I9305	Error	10804	Orderion.App	Error: Java.IO.EOFException: Exception of type 'Java.IO.EOFException' was thrown.
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at Java.Interop.JniEnvironment+InstanceMethods.CallIntMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00085] in /Users/builder/data/lanes/4009/9578cdcd/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11484 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualInt32Method (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00031] in /Users/builder/data/lanes/4009/9578cdcd/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:206 
  at Java.Net.HttpURLConnection.get_ResponseCode () [0x00000] in /Users/builder/data/lanes/4009/9578cdcd/source/monodroid/src/Mono.Android/platforms/android-25/src/generated/Java.Net.HttpURLConnection.cs:505 
  at Xamarin.Android.Net.AndroidClientHandler+<DoProcessRequest>c__async1+<DoProcessRequest>c__AnonStorey3.<>m__0 () [0x00000] in /Users/builder/data/lanes/4009/9578cdcd/source/xamarin-android/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:271 
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x00012] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:680 
  at System.Threading.Tasks.Task.Execute () [0x00016] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 
03-11 17:29:05.920	Samsung GT-I9305	Error	10804	Orderion.App	--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/4009/f3074d2c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 
  at Xamarin.Android.Net.AndroidClientHandler+<DoProcessRequest>c__async1.MoveNext () [0x00276] in /Users/builder/data/lanes/4009/9578cdcd/source/xamarin-android/src/Mono.Android/Xamarin.Android.Net/AndroidClientHandler.cs:271
Comment 1 Marek Habersack 2017-03-13 16:26:31 UTC
Can you attach a small, self-contained, app that reproduces the issue? Thanks!
Comment 2 Hrvoje 2017-03-15 21:32:00 UTC
Sorry,

It was locking issue in separate threads that caused the exception.