Bug 7923 - Application crashes when calling webservice through VPN
Summary: Application crashes when calling webservice through VPN
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.0.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-10-22 09:37 UTC by karol.sotomski
Modified: 2013-12-23 19:01 UTC (History)
7 users (show)

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


Attachments
device crash file (23.08 KB, application/octet-stream)
2012-10-23 04:01 UTC, karol.sotomski
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 karol.sotomski 2012-10-22 09:37:41 UTC
Hi,


there is a bug in the MonoTouch.CoreFoundation.CFNetwork that causes application crash without throwing an exception.

It seems that there is a null passed from library to native API within CopyProxiesForAutoConfigurationScript method.

This bug may be hard to trace because it comes only in to effect when an application is trying to access Web service through Junos VPN (or maybe other VPNs as well). When application is connecting over WiFi without VPN the bug does not occur.

Best regards
Karol

---- Application log:

Please ensure your device is connected...
Connected to: iPhone (user)
Launching /private/var/mobile/Applications/A0508025-17A0-4409-8552-4C0BB9B2830F/GigasetMobileOffice.app -debugtrack -monodevelop-port 10000 -connection-mode usb
Loaded assembly: /private/var/mobile/Applications/A0508025-17A0-4409-8552-4C0BB9B2830F/GigasetMobileOffice.app/Mono.Security.dll [External]
Loaded assembly: /private/var/mobile/Applications/A0508025-17A0-4409-8552-4C0BB9B2830F/GigasetMobileOffice.app/System.dll [External]
Loaded assembly: /private/var/mobile/Applications/A0508025-17A0-4409-8552-4C0BB9B2830F/GigasetMobileOffice.app/System.Core.dll [External]
Loaded assembly: /private/var/mobile/Applications/A0508025-17A0-4409-8552-4C0BB9B2830F/GigasetMobileOffice.app/monotouch.dll [External]
Loaded assembly: /private/var/mobile/Applications/A0508025-17A0-4409-8552-4C0BB9B2830F/GigasetMobileOffice.app/System.Xml.dll [External]
Loaded assembly: /private/var/mobile/Applications/A0508025-17A0-4409-8552-4C0BB9B2830F/GigasetMobileOffice.app/System.Web.Services.dll [External]
Loaded assembly: /private/var/mobile/Applications/A0508025-17A0-4409-8552-4C0BB9B2830F/GigasetMobileOffice.app/GigasetMobileOffice.exe
Thread started: Finalizer
Resolved pending breakpoint at '/Users/admin/Projects/GigasetMobileOffice/GigasetMobileOffice/ContactsTableViewController.cs:57' to Void GigasetMobileOffice.ContactsTableViewController:btnRefresh (UIBarButtonItem) [0x00000].
Stacktrace:

 at MonoTouch.CoreFoundation.CFNetwork.CopyProxiesForAutoConfigurationScript (MonoTouch.Foundation.NSString,MonoTouch.Foundation.NSUrl) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreFoundation/CFProxySupport.cs:474
 at MonoTouch.CoreFoundation.CFNetwork.GetProxiesForAutoConfigurationScript (MonoTouch.Foundation.NSString,MonoTouch.Foundation.NSUrl) [0x00028] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreFoundation/CFProxySupport.cs:490
 at MonoTouch.CoreFoundation.CFNetwork.GetProxiesForAutoConfigurationScript (MonoTouch.Foundation.NSString,System.Uri) [0x0003a] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreFoundation/CFProxySupport.cs:517
 at MonoTouch.CoreFoundation.CFNetwork/CFWebProxy.GetProxyUriFromScript (MonoTouch.Foundation.NSString,System.Uri) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreFoundation/CFProxySupport.cs:703
 at MonoTouch.CoreFoundation.CFNetwork/CFWebProxy.GetProxy (System.Uri) [0x0006d] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreFoundation/CFProxySupport.cs:744
 at MonoTouch.CoreFoundation.CFNetwork/CFWebProxy.IsBypassed (System.Uri) [0x00017] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreFoundation/CFProxySupport.cs:776
 at System.Net.ServicePointManager.FindServicePoint (System.Uri,System.Net.IWebProxy) [0x00020] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/ServicePointManager.cs:306
 at System.Net.HttpWebRequest.GetServicePoint () [0x00027] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:631
 at System.Net.HttpWebRequest.BeginGetRequestStream (System.AsyncCallback,object) [0x001ae] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:718
 at System.Net.HttpWebRequest.GetRequestStream () [0x0000d] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:748
 at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (string,object[]) [0x00069] in /Developer/MonoTouch/Source/mono/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapHttpClientProtocol.cs:367
 at GigasetMobileOffice.HRService.Service.getLatestVersionOfGMO () [0x00000] in /Users/admin/Projects/GigasetMobileOffice/GigasetMobileOffice/Web References/HRService/Reference.cs:725
 at GigasetMobileOffice.DataHelper.CheckForUpdatesSynch () [0x0002e] in /Users/admin/Projects/GigasetMobileOffice/GigasetMobileOffice/DataHelper.cs:290
 at GigasetMobileOffice.UpdatesController.btnRefresh (MonoTouch.UIKit.UIBarButtonItem) [0x00000] in /Users/admin/Projects/GigasetMobileOffice/GigasetMobileOffice/UpdatesController.cs:56
 at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>
 at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
 at GigasetMobileOffice.Application.Main (string[]) [0x00000] in /Users/admin/Projects/GigasetMobileOffice/GigasetMobileOffice/Main.cs:17
 at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

	0   GigasetMobileOffice                 0x0063c91d mono_handle_native_sigsegv + 244
	1   GigasetMobileOffice                 0x00603d25 mono_sigsegv_signal_handler + 172
	2   libsystem_c.dylib                   0x3337fe93 _sigtramp + 42
	3   CoreFoundation                      0x373e46f7 CFRelease + 1098
	4   GigasetMobileOffice                 0x001695cc wrapper_managed_to_native_MonoTouch_CoreFoundation_CFNetwork_CFNetworkCopyProxiesForAutoConfigurationScript_intptr_intptr + 68
	5   GigasetMobileOffice                 0x0013e05c MonoTouch_CoreFoundation_CFNetwork_GetProxiesForAutoConfigurationScript_MonoTouch_Foundation_NSString_MonoTouch_Foundation_NSUrl + 72
	6   GigasetMobileOffice                 0x0013e23c MonoTouch_CoreFoundation_CFNetwork_GetProxiesForAutoConfigurationScript_MonoTouch_Foundation_NSString_System_Uri + 140
	7   GigasetMobileOffice                 0x0013ea74 MonoTouch_CoreFoundation_CFNetwork_CFWebProxy_GetProxyUriFromScript_MonoTouch_Foundation_NSString_System_Uri + 36
	8   GigasetMobileOffice                 0x0013ec38 MonoTouch_CoreFoundation_CFNetwork_CFWebProxy_GetProxy_System_Uri + 248
	9   GigasetMobileOffice                 0x0013ed60 MonoTouch_CoreFoundation_CFNetwork_CFWebProxy_IsBypassed_System_Uri + 60
	10  GigasetMobileOffice                 0x0032fb28 System_Net_ServicePointManager_FindServicePoint_System_Uri_System_Net_IWebProxy + 136
	11  GigasetMobileOffice                 0x00324cc0 System_Net_HttpWebRequest_GetServicePoint + 104
	12  GigasetMobileOffice                 0x00324fac System_Net_HttpWebRequest_BeginGetRequestStream_System_AsyncCallback_object + 680
	13  GigasetMobileOffice                 0x00325268 System_Net_HttpWebRequest_GetRequestStream + 60
	14  GigasetMobileOffice                 0x0000c050 System_Web_Services_Protocols_SoapHttpClientProtocol_Invoke_string_object__ + 388
	15  GigasetMobileOffice                 0x000ad67c GigasetMobileOffice_HRService_Service_getLatestVersionOfGMO + 196
	16  GigasetMobileOffice                 0x000b8074 GigasetMobileOffice_DataHelper_CheckForUpdatesSynch + 456
	17  GigasetMobileOffice                 0x000b2f00 GigasetMobileOffice_UpdatesController_btnRefresh_MonoTouch_UIKit_UIBarButtonItem + 144
	18  GigasetMobileOffice                 0x004f7400 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
	19  GigasetMobileOffice                 0x006052fb mono_jit_runtime_invoke + 1054
	20  GigasetMobileOffice                 0x0065fbff mono_runtime_invoke + 90
	21  GigasetMobileOffice                 0x005fdc1d native_to_managed_trampoline_GigasetMobileOffice_UpdatesController_btnRefresh + 220
	22  UIKit                               0x35f3a0ad <redacted> + 72
	23  UIKit                               0x35f3a135 <redacted> + 120
	24  UIKit                               0x35f3a0ad <redacted> + 72
	25  UIKit                               0x35f3a05f <redacted> + 30
	26  UIKit                               0x35f3a03d <redacted> + 44
	27  UIKit                               0x35f398f3 <redacted> + 502
	28  UIKit                               0x35f39de9 <redacted> + 488
	29  UIKit                               0x35e625f9 <redacted> + 524
	30  UIKit                               0x35e4f809 <redacted> + 380
	31  UIKit                               0x35e4f123 <redacted> + 6154
	32  GraphicsServices                    0x373185a3 <redacted> + 590
	33  GraphicsServices                    0x373181d3 <redacted> + 34
	34  CoreFoundation                      0x37478173 <redacted> + 34
	35  CoreFoundation                      0x37478117 <redacted> + 138
	36  CoreFoundation                      0x37476f99 <redacted> + 1384
	37  CoreFoundation                      0x373e9ebd CFRunLoopRunSpecific + 356
	38  CoreFoundation                      0x373e9d49 CFRunLoopRunInMode + 104
	39  GraphicsServices                    0x373172eb GSEventRunModal + 74
	40  UIKit                               0x35ea3301 UIApplicationMain + 1120
	41  GigasetMobileOffice                 0x0016cc60 wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 240
	42  GigasetMobileOffice                 0x00094b30 GigasetMobileOffice_Application_Main_string__ + 152
	43  GigasetMobileOffice                 0x004f7400 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
	44  GigasetMobileOffice                 0x006052fb mono_jit_runtime_invoke + 1054
	45  GigasetMobileOffice                 0x0065fbff mono_runtime_invoke + 90
	46  GigasetMobileOffice                 0x0066269b mono_runtime_exec_main + 306
	47  GigasetMobileOffice                 0x00665927 mono_runtime_run_main + 482
	48  GigasetMobileOffice                 0x006170d7 mono_jit_exec + 94
	49  GigasetMobileOffice                 0x006a2e54 main + 2216
	50  libdyld.dylib                       0x37518b20 <redacted> + 0

=================================================================
Got a SIGSEGV 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 Sebastien Pouliot 2012-10-22 10:17:09 UTC
A crash on CFRelease does not look to be null-related (the code checks for nulls and the stack trace line numbers are not on the null checks). c.c. jeff

Could you attach the device crash log ? that will tell us what the other threads were doing at the same time.
Comment 2 Jeffrey Stedfast 2012-10-22 10:44:47 UTC
the native bt makes it look like CFNetworkCopyProxiesForAutoConfigurationScript is calling CFRelease directly, but it's not afaict.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2012-10-22 18:26:06 UTC
Karol, I sent you a modified version of monotouch.dll with additional diagnostics from support, were you able to try it out?
Comment 4 karol.sotomski 2012-10-23 04:01:52 UTC
Created attachment 2777 [details]
device crash file
Comment 5 karol.sotomski 2012-10-23 04:03:21 UTC
@Sebastien

i attached crash file.

@Rolf

I did not receive it because our mail system blocks zip files. Could you send it once more with extension changed to something like ".___".
Comment 9 Rolf Bjarne Kvinge [MSFT] 2012-10-24 07:26:12 UTC
With the patched monotouch.dll null should not be passed under any circumstances to the underlying native method, so it must be something else.

I have however no idea what it might be, so I'd probably need a test case to figure it out.

In any case here are a few ideas to narrow it down:
* Try another VPN to see if it's specific to the VPN you're using.
* Try calling System.Net.ServicePointManager.FindServicePoint (uri, proxy) with different uris to see if it's uri-specific.
Comment 10 karol.sotomski 2012-10-30 12:43:14 UTC
I have tested without errors following code:

String url = "https://app-intranet-pl.giga.gigaset.com/HRService/Service.asmx";
System.Uri uri = new Uri(url);
IWebProxy proxy = null;
System.Net.ServicePoint sp = System.Net.ServicePointManager.FindServicePoint (uri, proxy);

where url is the address of our web service. Code above do not crash the app, but calling web service still does.

Could you provide me with a modified dll that will log content of uri and proxy inside System.Net.HttpWebRequest.GetServicePoint ()  just before entering FindServicePoint method within
  at System.Net.ServicePointManager.FindServicePoint (System.Uri,System.Net.IWebProxy) [0x00020] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/ServicePointManager.cs:306
Comment 12 Eric Fikus 2013-09-18 18:30:23 UTC
Any update on this?  We've seen this crash in logs submitted by users. I was able to reproduce by running our app after installing Orvano Protect from the app store.

This is with Xamarin.iOS 6.2.7.1.
Comment 13 Eric Fikus 2013-09-18 18:34:27 UTC
Misspelled the name of the app above, it is "Onavo Protect".
Comment 14 Rolf Bjarne Kvinge [MSFT] 2013-09-20 04:36:50 UTC
Fixed.

mono/master: db195e8e90375dacdd50e7263a84e8f291878c82

The fix will be included in the next non-hotfix release of Xamarin.iOS (I don't know what version number that will be now, but release notes will state if it's a hotfix release or not).
Comment 15 Rolf Bjarne Kvinge [MSFT] 2013-09-20 04:37:23 UTC
Additional commit info: monotouch/master: 3c53ff950aa413d16d4c4a586ea389f40a69806a
Comment 16 Rolf Bjarne Kvinge [MSFT] 2013-09-20 05:01:19 UTC
QA: this can be tested (on device only) by installing and enabling the "Onavo Protect" app, and then run monotouch-test.
Comment 17 Eric Fikus 2013-10-28 19:10:39 UTC
Can you confirm this is included in 7.0.3? I don't see it listed in the release notes.
Comment 18 Rolf Bjarne Kvinge [MSFT] 2013-10-28 20:39:12 UTC
This will be included in 7.0.3 - which is already in the alpha channel, if you want to try it out.
Comment 20 Rolf Bjarne Kvinge [MSFT] 2013-11-08 11:49:25 UTC
I can't confirm a specific date, but it'll hopefully be within a week or so.
Comment 21 Pierre A. 2013-12-05 05:36:18 UTC
We are currently using 7.0.4.209 and one of our customer (using also Onavo protect) was unable to start our App (crash at every boot with same callstack as above).

We have asked him to uninstall Onavo Protect: no more crash for our App.

It seems that the bug is NOT RESOLVED or at least that fix is not released.


Can please you confirm?
Comment 22 Rolf Bjarne Kvinge [MSFT] 2013-12-05 08:20:28 UTC
Pierre, the test case I have doesn't fail anymore with 7.0.4, so maybe something else is causing your crash. Could you upload a test project that crashes for you when Onavo Protect is in use?
Comment 23 Pierre A. 2013-12-05 09:07:46 UTC
We can provide to you the end-user crashlog (that is very similar to the one above) and we have troubleshoot the end-user case making him uninstall Onavo.

We have also experienced the crash by ourselves:
1) install our App
2) launch our App : OK
3) relaunch our App: OK x several attempts
4) install Onavo protect and laucnh it.
5) launch our App: KO
6) relaunching our App: KO x several attempts 
7) removing completely Onavo protect.
8) uninstalling our App.
9) rebooting iPad
10) reinstalling our App
11) launching our App : OK x several attempts

Redo all steps from 1 to 11 several times: same behavior every time.
Comment 24 Rolf Bjarne Kvinge [MSFT] 2013-12-05 09:30:13 UTC
Pierre, could we get access to your app? I don't think I need access to the source code, just zipping up the directory obj/iPhone/Debug/mtouch-cache after a successful build would be enough.
Comment 25 Pierre A. 2013-12-05 10:15:46 UTC
I have just send to you an email with a link to download it.
Comment 26 Eric Fikus 2013-12-10 14:11:48 UTC
Any update on this? I can't seem to reproduce the crash with my app anymore, but I'd like to confirm that it's fixed in all cases so we can pass that along to users who have encountered it.
Comment 27 Rolf Bjarne Kvinge [MSFT] 2013-12-12 08:47:03 UTC
Eric, I have a test app where it still crashes, but I have not been able to track down why (yet). The current hypothesis is that it's a bug in iOS7 (I can't reproduce the crash with iOS6), but it's not more than a hypothesis.

In addition the conditions required for it to crash seem fairly strict, so if you can't reproduce any crash with the "Onavo" VPN app and iOS7, I wouldn't worry.
Comment 28 Rolf Bjarne Kvinge [MSFT] 2013-12-23 19:01:49 UTC
Pierre, I've been able to figure out a workaround [1]. This will not be included in the upcoming 7.0.6 release (it's too late), but might get into the next release after that (too early to tell at this point though).

mono/master: 3c928782dd115309e54332e7971af1f7f677ff57
monotouch/master: 9c5cdb0f45f74bc2ae532a25f4148ce1898a87bb


[1] The Onavo proxy uses a javascript proxy configuration script which has to be executed for every request. Apparently iOS does not like this script to be executed on different threads (even if not executed simultaneously), so the solution was to start up a dedicated thread doing only this: https://github.com/mono/mono/commit/3c928782dd115309e54332e7971af1f7f677ff57