Bug 19914 - Crash when downloading files with HttpWebRequest
Summary: Crash when downloading files with HttpWebRequest
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 7.2.2
Hardware: Macintosh Mac OS
: High normal
Target Milestone: Untriaged
Assignee: Martin Baulig
URL:
Depends on:
Blocks:
 
Reported: 2014-05-20 03:39 UTC by Christer Nordvik
Modified: 2014-07-22 14:00 UTC (History)
4 users (show)

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


Attachments
Testapp (21.00 KB, application/zip)
2014-05-20 03:39 UTC, Christer Nordvik
Details


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 FIXED

Description Christer Nordvik 2014-05-20 03:39:07 UTC
Steps to reproduce: 

1. Start app
2. Click button
3. Wait for a time period like 10 minutes (not sure how long you must wait)
4. Click button
5. Crash

This happens a lot and is very critical to our production app since it prevents us from upgrading it. 

Xamarin.iOS
Version: 7.2.2.2 (Business Edition)
Hash: db4427f
Branch: 
Build date: 2014-04-22 12:49:14-0400


Output from a testrun: 

2014-05-20 09:20:26.758 CrashTest[6827:b907] 09:20:26 - 200
2014-05-20 09:20:26.759 CrashTest[6827:841b] 09:20:26 - 200
2014-05-20 09:20:26.762 CrashTest[6827:7a1b] 09:20:26 - 200
2014-05-20 09:20:26.762 CrashTest[6827:8d2b] 09:20:26 - 200
2014-05-20 09:20:26.765 CrashTest[6827:a217] 09:20:26 - 200
2014-05-20 09:20:26.766 CrashTest[6827:8113] 09:20:26 - 200
2014-05-20 09:20:26.766 CrashTest[6827:b027] 09:20:26 - 200
2014-05-20 09:20:26.766 CrashTest[6827:942b] 09:20:26 - 200
2014-05-20 09:20:26.767 CrashTest[6827:2917] 09:20:26 - 200
2014-05-20 09:20:26.866 CrashTest[6827:9917] 09:20:26 - 200
2014-05-20 09:20:39.294 CrashTest[6827:a217] 09:20:39 - 200
2014-05-20 09:20:39.295 CrashTest[6827:b027] 09:20:39 - 200
2014-05-20 09:20:39.295 CrashTest[6827:b907] 09:20:39 - 200
2014-05-20 09:20:39.295 CrashTest[6827:8113] 09:20:39 - 200
2014-05-20 09:20:39.296 CrashTest[6827:9917] 09:20:39 - 200
2014-05-20 09:20:39.297 CrashTest[6827:942b] 09:20:39 - 200
2014-05-20 09:20:39.297 CrashTest[6827:8d2b] 09:20:39 - 200
2014-05-20 09:20:39.297 CrashTest[6827:7c1f] 09:20:39 - 200
2014-05-20 09:20:39.298 CrashTest[6827:2917] 09:20:39 - 200
2014-05-20 09:20:39.298 CrashTest[6827:a833] 09:20:39 - 200

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at System.Net.ServicePoint.SendRequest (System.Net.HttpWebRequest request, System.String groupName) [0x00072] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/ServicePoint.cs:430 
  at System.Net.HttpWebRequest.GetResponseAsyncCB2 (System.Net.WebAsyncResult aread) [0x00094] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:966 
  at System.Net.HttpWebRequest.BeginGetResponse (System.AsyncCallback callback, System.Object state) [0x000e8] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:919 
  at CrashTest.io.AsyncHttp.Execute (CrashTest.io.UrlParams urlParams) [0x00084] in /Users/cnordvik/projects/CrashTest/CrashTest/AsyncHttp.cs:50 
  at CrashTest.CrashTestViewController.StartTest () [0x00024] in /Users/cnordvik/projects/CrashTest/CrashTest/CrashTestViewController.cs:40 
  at CrashTest.CrashTestViewController.<ViewDidLoad>m__0 (System.Object sender, System.EventArgs e) [0x00001] in /Users/cnordvik/projects/CrashTest/CrashTest/CrashTestViewController.cs:47 
  at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00007] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:33 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 
  at CrashTest.Application.Main (System.String[] args) [0x00008] in /Users/cnordvik/projects/CrashTest/CrashTest/Main.cs:16 
2014-05-20 09:29:35.446 CrashTest[6827:70b] Unhandled managed exception: Object reference not set to an instance of an object (System.NullReferenceException)
  at System.Net.ServicePoint.SendRequest (System.Net.HttpWebRequest request, System.String groupName) [0x00072] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/ServicePoint.cs:430 
  at System.Net.HttpWebRequest.GetResponseAsyncCB2 (System.Net.WebAsyncResult aread) [0x00094] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:966 
  at System.Net.HttpWebRequest.BeginGetResponse (System.AsyncCallback callback, System.Object state) [0x000e8] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:919 
  at CrashTest.io.AsyncHttp.Execute (CrashTest.io.UrlParams urlParams) [0x00084] in /Users/cnordvik/projects/CrashTest/CrashTest/AsyncHttp.cs:50 
  at CrashTest.CrashTestViewController.StartTest () [0x00024] in /Users/cnordvik/projects/CrashTest/CrashTest/CrashTestViewController.cs:40 
  at CrashTest.CrashTestViewController.<ViewDidLoad>m__0 (System.Object sender, System.EventArgs e) [0x00001] in /Users/cnordvik/projects/CrashTest/CrashTest/CrashTestViewController.cs:47 
  at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00007] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:33 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 
  at CrashTest.Application.Main (System.String[] args) [0x00008] in /Users/cnordvik/projects/CrashTest/CrashTest/Main.cs:16 
mono-rt: Stacktrace:


mono-rt: 
Native stacktrace:


mono-rt: 	0   CrashTest                           0x000c3977 mono_handle_native_sigsegv + 327

mono-rt: 	1   CrashTest                           0x000ce7ba sigabrt_signal_handler + 122

mono-rt: 	2   libsystem_platform.dylib            0x054dbdeb _sigtramp + 43

mono-rt: 	3   ???                                 0xffffffff 0x0 + 4294967295

mono-rt: 	4   libsystem_sim_c.dylib               0x0533a9c9 abort + 127

mono-rt: 	5   CrashTest                           0x0024cd33 monotouch_unhandled_exception_handler + 291

mono-rt: 	6   CrashTest                           0x000c41bb mono_invoke_unhandled_exception_hook + 91

mono-rt: 	7   CrashTest                           0x000c31cc mono_handle_exception_internal + 6620

mono-rt: 	8   CrashTest                           0x000c17e9 mono_handle_exception + 41

mono-rt: 	9   CrashTest                           0x0005d210 altstack_handle_and_restore + 80

mono-rt: 	10  ???                                 0x1665624b 0x0 + 375743051

mono-rt: 	11  ???                                 0x16652bcc 0x0 + 375729100

mono-rt: 	12  ???                                 0x166520d8 0x0 + 375726296

mono-rt: 	13  ???                                 0x16637bd9 0x0 + 375618521

mono-rt: 	14  ???                                 0x16637a37 0x0 + 375618103

mono-rt: 	15  ???                                 0x166379bc 0x0 + 375617980

mono-rt: 	16  ???                                 0x1663798e 0x0 + 375617934

mono-rt: 	17  ???                                 0x1325fb11 0x0 + 321256209

mono-rt: 	18  CrashTest                           0x000f575b mono_jit_runtime_invoke + 843

mono-rt: 	19  CrashTest                           0x00193d5f mono_runtime_invoke + 127

mono-rt: 	20  CrashTest                           0x00243a2f monotouch_trampoline + 4991

mono-rt: 	21  libobjc.A.dylib                     0x05028880 -[NSObject performSelector:withObject:withObject:] + 77

mono-rt: 	22  UIKit                               0x029f43b9 -[UIApplication sendAction:to:from:forEvent:] + 108

mono-rt: 	23  UIKit                               0x029f4345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61

mono-rt: 	24  UIKit                               0x02af5bd1 -[UIControl sendAction:to:forEvent:] + 66

mono-rt: 	25  UIKit                               0x02af5fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577

mono-rt: 	26  UIKit                               0x02af5243 -[UIControl touchesEnded:withEvent:] + 641

mono-rt: 	27  UIKit                               0x02a33ddd -[UIWindow _sendTouchesForEvent:] + 852

mono-rt: 	28  UIKit                               0x02a349d1 -[UIWindow sendEvent:] + 1117

mono-rt: 	29  UIKit                               0x02a065f2 -[UIApplication sendEvent:] + 242

mono-rt: 	30  UIKit                               0x029f0353 _UIApplicationHandleEventQueue + 11455

mono-rt: 	31  CoreFoundation                      0x015c177f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15

mono-rt: 	32  CoreFoundation                      0x015c110b __CFRunLoopDoSources0 + 235

mono-rt: 	33  CoreFoundation                      0x015de1ae __CFRunLoopRun + 910

mono-rt: 	34  CoreFoundation                      0x015dd9d3 CFRunLoopRunSpecific + 467

mono-rt: 	35  CoreFoundation                      0x015dd7eb CFRunLoopRunInMode + 123

mono-rt: 	36  GraphicsServices                    0x062625ee GSEventRunModal + 192

mono-rt: 	37  GraphicsServices                    0x0626242b GSEventRun + 104

mono-rt: 	38  UIKit                               0x029f2f9b UIApplicationMain + 1225

mono-rt: 	39  ???                                 0x1326cd34 0x0 + 321310004

mono-rt: 	40  ???                                 0x1326bbc4 0x0 + 321305540

mono-rt: 	41  ???                                 0x1326b948 0x0 + 321304904

mono-rt: 	42  ???                                 0x1326b9d7 0x0 + 321305047

mono-rt: 	43  CrashTest                           0x000f575b mono_jit_runtime_invoke + 843

mono-rt: 	44  CrashTest                           0x00193d5f mono_runtime_invoke + 127

mono-rt: 	45  CrashTest                           0x00199871 mono_runtime_exec_main + 401

mono-rt: 	46  CrashTest                           0x00199634 mono_runtime_run_main + 628

mono-rt: 	47  CrashTest                           0x000541fd mono_jit_exec + 93

mono-rt: 	48  CrashTest                           0x00234c70 main + 2784

mono-rt: 	49  CrashTest                           0x00002c15 start + 53

mono-rt: 
=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================
Comment 1 Christer Nordvik 2014-05-20 03:39:45 UTC
Created attachment 6841 [details]
Testapp
Comment 2 Prashant manu 2014-05-20 04:52:33 UTC
I have checked this issue with following builds:

Mac Maverick
X.S 4.2.5(Build 0)
Git revision: 95ac543f224a70960a9ab71e24ce341eb87de06f
X.iOS 7.2.2.2

I am also able to reproduce this issue. When I click on button it worked fine after clicking again on this button after some time (10 minutes and above), Application gets crashed.

Exception details: https://gist.github.com/saurabh360/ff42d23039ba8fcffebb
Application Output: https://gist.github.com/saurabh360/3a4cb37f263fc82908ba
iOS Device log: https://gist.github.com/saurabh360/910f3fee9b11f515fa85
I am not seeing symbolicated log for this app in Xcode organizer.
Comment 3 Tom Philpot 2014-05-20 13:52:51 UTC
You can reduce the time needed to wait by adding the following to AsycnHttp on line 33.

			request.ServicePoint.MaxIdleTime = 30000; // 30 seconds
Comment 4 Tom Philpot 2014-05-20 13:55:40 UTC
Here's the inner stack trace:

  at System.Net.ServicePoint.SendRequest (System.Net.HttpWebRequest request, System.String groupName) [0x00072] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/ServicePoint.cs:430 
  at System.Net.HttpWebRequest.GetResponseAsyncCB2 (System.Net.WebAsyncResult aread) [0x00094] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:966 
  at System.Net.HttpWebRequest.BeginGetResponse (System.AsyncCallback callback, System.Object state) [0x000e8] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:919 
  at CrashTest.io.AsyncHttp.Execute (CrashTest.io.UrlParams urlParams) [0x000a5] in /Users/tom.philpot/Downloads/CrashTest/CrashTest/AsyncHttp.cs:51 
  at CrashTest.CrashTestViewController.StartTest () [0x00024] in /Users/tom.philpot/Downloads/CrashTest/CrashTest/CrashTestViewController.cs:40 
  at CrashTest.CrashTestViewController.<ViewDidLoad>m__0 (System.Object sender, System.EventArgs e) [0x00001] in /Users/tom.philpot/Downloads/CrashTest/CrashTest/CrashTestViewController.cs:47 
  at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00007] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:33 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 
  at CrashTest.Application.Main (System.String[] args) [0x00008] in /Users/tom.philpot/Downloads/CrashTest/CrashTest/Main.cs:16
Comment 5 Christer Nordvik 2014-06-03 08:38:45 UTC
Any updates on this? My app crashes all the time with this version so I would think this affects a large number of Xamarin.iOS apps and therefore is a bit critical? Or is there something specific in the way that I am using HttpWebRequest that makes this affect my app more than others?
Comment 6 Rolf Bjarne Kvinge [MSFT] 2014-06-09 08:06:18 UTC
@Christer, until an update has been released, you can download and install any older version of Xamarin.iOS from your Xamarin Store account: https://store.xamarin.com/account/my/subscription/downloads
Comment 7 Christer Nordvik 2014-06-09 16:19:57 UTC
Yes, I had to do that to be ready for the World Cup 2014 :-) 

But I still think it is strange that this bug which seems super critical to me, doesn't get a hotfix or something when it is now 3 weeks old. Shouldn't you warn people to not use the latest Xamarin.iOS version? It would have been a disaster for us if we released this version and it was very close since the app was under review when we discovered that the app crashed randomly.
Comment 8 PJ 2014-07-22 14:00:10 UTC
This was fixed in the HTTP hotfix release on June 20th, the Xamarin.iOS 7.2.4.4 release. 

The test case in comment 1 (plus the modification in comment 3) passes for me on our current stable release, X.iOS 7.2.5.5 [1]. It fails on the release before the HTTP hotfix release, X.iOS 7.2.3.39 [2].

Here is the commit with the fix: https://github.com/mono/mono/commit/959fd8c59f73be3bfd794342870e3034280a978e

That commit has also been applied to master: https://github.com/mono/mono/commit/bad5ef8453b25f9bf7e31487b37153e5a35669e8

[1] https://gist.github.com/pjbeaman/62b57caca016457415d5
[2] https://gist.github.com/pjbeaman/63e2610c922f702bd2db