Bug 29423 - SIGSEGV on concurrent http-requests
Summary: SIGSEGV on concurrent http-requests
Alias: None
Product: Android
Classification: Xamarin
Component: Debugger ()
Version: 5.0
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-04-27 10:10 UTC by Audun Steinholm
Modified: 2017-09-18 20:54 UTC (History)
4 users (show)

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

Code to reproduce the problem (4.70 KB, text/plain)
2015-04-27 10:10 UTC, Audun Steinholm
build info, ide log, app output, and logcat (10.25 KB, application/x-zip-compressed)
2015-05-07 05:50 UTC, Audun Steinholm

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:

Description Audun Steinholm 2015-04-27 10:10:12 UTC
Created attachment 10915 [details]
Code to reproduce the problem

Debugging an Android app that does many concurrent http-requests can cause the app to exit with signal 11.

We've tested different http-stacks without being able to nail down what specifically is causing the problem.

The app does not appear crash if run in Release mode.
The app crashes when debugging in Visual Studio or Xamarin Studio
The app does not crash if run with msbuild /t:Install, msbuild /t:_Gdb
This has been reproduced on a Nexus 9 tablet and a Samsung Galaxy S5 phone.
It usually takes between 20 minutes and two minutes for the app to crash.

Attached code to demonstrate a minimal app with this problem. Create a New blank android app and use the given file as MainActivity.

The demo app has one button. On button click, the app will post 3 concurrent http-request loops that will use Java.Net.HttpURLConnection to GET a web page. The content is read and summarized, just to do something with the data.

This triggers that same problem that we're seeing in our app that concurrently fetches thumbnail images from a server in a similar manner.

Note: Provoking the crash is not entirely reliable. Sometimes it triggers an unhandled exception instead of exiting with signal 11. This appears to happen if too many requests are started before we get around to reading. It is also affected by the content of the url. If the content is too short, the app may not crash.

The android debugging log looks something like this when the app exits:
04-27 15:05:08.701: D/Test(744): <!DOCTYPE html><html><head>  <meta ht
04-27 15:05:08.706: D/Test(744): <!DOCTYPE html><html><head>  <meta ht
04-27 15:05:08.927: I/WindowState(811): WIN DEATH: Window{3cb1a8a u0 App1.App1/app1.MainActivity}
04-27 15:05:08.967: I/Zygote(570): Process 744 exited due to signal (11)
04-27 15:05:08.986: I/ActivityManager(811): Process App1.App1 (pid 744) has died
04-27 15:05:08.987: W/ActivityManager(811): Force removing ActivityRecord{7e749e8 u0 App1.App1/app1.MainActivity t1108}: app died, no saved state
04-27 15:05:09.029: W/InputMethodManagerService(811): Got RemoteException sending setActive(false) notification to pid 744 uid 10082
04-27 15:05:09.070: W/LocationOracleImpl(2536): Best location was null

Visual Studio shows this error dialog:
Debugger lost connection to the running application. Likely this means the application terminated unexpectedly.
Comment 1 Audun Steinholm 2015-04-29 05:48:13 UTC
That should be between 20 secs and 2 minutes for the app to crash.
Comment 2 Udham Singh 2015-05-06 11:44:58 UTC
I have tried to reproduce this issue with the help of code provided in bug description but not able to reproduce this. To reproduce this issue I have run the app many times on Samsung Galaxy S5 (android 5.0) and Google Nexus 5 (android 5.0.1), wait for some time (~5 minutes) but did not get crash.

Could you please provide your complete build info, ide logs, application output and adb logcat? so that developer can figure out whats going on from the stack trace.

You can get complete build info via 'XS > Help > About > Show Details > Copy Info and paste it here', ide logs via 'XS > Help > Open Log Directory and get the latest Ide logs'.

Comment 3 Audun Steinholm 2015-05-07 05:50:16 UTC
Created attachment 11112 [details]
build info, ide log, app output, and logcat

added requested info
Comment 4 Jon Douglas [MSFT] 2017-09-14 18:45:09 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Android. If you are still experiencing the issue after updating your packages, please reopen this report.
Comment 5 Anonymous 2017-09-18 20:54:28 UTC
I'm running on VS 2017 (15.3.4) with Xamarin.Android and still running into this issue debugging on a Nexus 7 running Android 6.0.1 

It would be appreciated if you could reference what packages to upgrade and which versions are supposed to contain the fix. I can provide full IDE information and logcat output again if needed.