Bug 16798 - Random Crash in NSURLConnection
Summary: Random Crash in NSURLConnection
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 7.1.0.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
: 16797 ()
Depends on:
Reported: 2013-12-14 02:47 UTC by David Screve
Modified: 2016-05-24 20:56 UTC (History)
3 users (show)

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

Crash log (72.46 KB, application/octet-stream)
2013-12-18 08:12 UTC, David Screve

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 David Screve 2013-12-14 02:47:18 UTC
Assertion at ../../../../../mono/mono/utils/mono-threads.c:159, condition `result' not met
mono-rt: Native stacktrace:

mono-rt: 0 iLRistorante 0x00181d1d mono_handle_native_sigsegv + 349

mono-rt: 1 iLRistorante 0x0018ccea sigabrt_signal_handler + 122

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

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

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

mono-rt: 5 iLRistorante 0x002ce045 monoeg_g_logv + 181

mono-rt: 6 iLRistorante 0x002ce0ab monoeg_assertion_message + 43

mono-rt: 7 iLRistorante 0x002c3850 mono_thread_info_dettach + 0

mono-rt: 8 iLRistorante 0x001ce091 mono_gc_register_thread + 17

mono-rt: 9 iLRistorante 0x00283acb mono_thread_attach_full + 91

mono-rt: 10 iLRistorante 0x00283a69 mono_thread_attach + 25

mono-rt: 11 iLRistorante 0x001a8956 mono_jit_thread_attach + 54

mono-rt: 12 iLRistorante 0x002fec43 monotouch_switch_gchandle + 67

mono-rt: 13 iLRistorante 0x002feb2e monotouch_release_trampoline + 158

mono-rt: 14 Foundation 0x01be0409 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 102

mono-rt: 15 Foundation 0x01a68a6e -[NSURLConnectionInternalConnection invokeForDelegate:] + 119

mono-rt: 16 Foundation 0x01a689d6 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 208

mono-rt: 17 Foundation 0x01be054d -[NSURLConnectionInternal _withConnectionAndDelegate:] + 76

mono-rt: 18 Foundation 0x01a68d2a -[NSURLConnectionInternal _withConnectionDisconnectFromConnection] + 84

mono-rt: 19 Foundation 0x01a68ccc _NSURLConnectionReleaseClient + 33

mono-rt: 20 CFNetwork 0x00535ce1 _ZN27URLConnectionClient_Classic11setDelegateEPK24CFURLConnectionClient_V1 + 163

mono-rt: 21 CFNetwork 0x005cf64b ___ZN27URLConnectionClient_Classic15invalidateAsyncEP16dispatch_queue_sU13block_pointerFvvE_block_invoke_2 + 37

mono-rt: 22 CFNetwork 0x005cf5fd ___ZN27URLConnectionClient_Classic15invalidateAsyncEP16dispatch_queue_sU13block_pointerFvvE_block_invoke + 210

mono-rt: 23 CFNetwork 0x005cce20 ___ZNK25URLConnectionInstanceData19_withWorkQueueAsyncEPKcU13block_pointerFvvE_block_invoke + 17

mono-rt: 24 CFNetwork 0x0061a170 ___ZNK17CoreSchedulingSet13_performAsyncEPKcU13block_pointerFvvE_block_invoke79 + 31

mono-rt: 25 libdispatch.dylib 0x058c37f8 _dispatch_call_block_and_release + 15

mono-rt: 26 libdispatch.dylib 0x058d84b0 _dispatch_client_callout + 14

mono-rt: 27 libdispatch.dylib 0x058c607f _dispatch_queue_drain + 452

mono-rt: 28 libdispatch.dylib 0x058c5e7a _dispatch_queue_invoke + 128

mono-rt: 29 libdispatch.dylib 0x058c6e1f _dispatch_root_queue_drain + 83

mono-rt: 30 libdispatch.dylib 0x058c7137 _dispatch_worker_thread2 + 39

mono-rt: 31 libsystem_pthread.dylib 0x05c8edab _pthread_wqthread + 336

mono-rt: 32 libsystem_pthread.dylib 0x05c92cce start_wqthread + 30

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 Sebastien Pouliot 2013-12-14 10:36:07 UTC
mono-rt: 5 iLRistorante 0x002ce045 monoeg_g_logv + 181

^ the above means the mono runtime logged some information on the device's console before it crashed.

Can you retrieve this information ?
And also attach the symbolicated crash report ?

Or even better can you provide us a test case from which we could reproduce the issue ourselves ?

In any case please provide the version information about what you used: both the software* and the device(s) type and iOS version.

* The easiest way to get exact version information is to use the "Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" button and copy/paste the version informations (you can use the "Copy Information" button).
Comment 2 Sebastien Pouliot 2013-12-14 10:36:37 UTC
*** Bug 16797 has been marked as a duplicate of this bug. ***
Comment 3 David Screve 2013-12-14 13:27:42 UTC
Problem occurs mostly on simulator, and less on device....this is a random bug on a project that I cannot send to you.

I'll try to get a crash log on a true device.
Comment 4 Sebastien Pouliot 2013-12-15 11:09:37 UTC
That sounds like you're not keeping a reference to an instance (and similar to your UIAlertView report).

When an managed instance variable is without any reference then the GC then is free to collect it.

However it's possible that the native peer (of your managed instance) is still alive and it can callback into your code. If the managed instance does not exists then it will lead to a crash.

IOW it's important to understand the lifecycle of the objects you create - and keep the managed instance alive as long as they exists natively.
Comment 5 David Screve 2013-12-15 15:43:04 UTC
Do you mean that you didn't retain internally  reference to NSURLConnectionDelegate object unless one of my C# object maintain reference ?
Comment 6 Sebastien Pouliot 2013-12-16 15:07:06 UTC
No. The NSUrlConnection instance will keep a reference to it's assigned NSUrlConnectionDelegate.

OTOH a _local_ variable of NSUrlConnection might be GC'ed even if it's still alive/retained on the native side - and if it's disposed then it's delegate will be too.

Now I suspect a GC-related issue because of:

> Problem occurs mostly on simulator, and less on device....

because we run the GC much more often on the simulator to catch those specific cases.

Sadly without a small test case (no need for the complete project), to reproduce the issue it's hard to be more specific about this.
Comment 7 David Screve 2013-12-16 15:16:28 UTC
I cannot give you a small case that reproduce the bug...and this a confidential project, so I cannot give you  a test case...I'll try modify project to keep references retained and I'll keep you informed.
Comment 8 David Screve 2013-12-18 08:12:47 UTC
Created attachment 5686 [details]
Crash log

This is the crash log.
Comment 9 Rolf Bjarne Kvinge [MSFT] 2013-12-19 19:16:27 UTC
You're hitting an assert inside the Mono runtime, indicating that something has gone very bad.

Unfortunately whatever went bad occurred (possibly a long time) before the crash itself, so unfortunately the crash report doesn't explain exactly the conditions required for this to occur in the first place.

What this means is that we need some way of reproducing this crash ourselves (either a test project, or access to your real project), otherwise it will be impossible to find out what's happening.
Comment 10 Sebastien Pouliot 2016-05-24 20:56:47 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and re-open the bug report. Thanks!