Bug 19198 - (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain in Array.cs on Line 159
Summary: (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain i...
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 7.0.3.x
Hardware: All Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-04-21 10:57 UTC by Michael Stonis
Modified: 2014-05-08 16:22 UTC (History)
3 users (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 INVALID

Description Michael Stonis 2014-04-21 10:57:22 UTC
We have an application that will crash randomly on the line: 

(wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain in Array.cs on Line 159

So far, we have only seen this crash on iPhone 4S devices. Two of the crashes have occurred immediately after app start. The other came a minute or two after being in the application.

Two sample stack traces are below.

//* Start Stack Trace 1 *//
#	Binary Image Name	Address	Symbol
0	FlightScheduleProPilotiPhone	0x000e0bd0	testflight_backtrace
1	FlightScheduleProPilotiPhone	0x000e0488	TFSignalHandler
2	libsystem_platform.dylib	0x3b27df92	_sigtramp
3	vImage	0x2f3ce26c	vPermuteChannels_ARGB8888
4	ImageIO	0x3112b154	copyImageBlockSetPNG
5	ImageIO	0x3112a27e	ImageProviderCopyImageBlockSetCallback
6	CoreGraphics	0x3046744c	CGImageProviderCopyImageBlockSetWithOptions
7	QuartzCore	0x328a1104	_ZN2CA6Render12create_imageEP7CGImageP12CGColorSpacej
8	QuartzCore	0x328a05ae	_ZN2CA6Render10copy_imageEP7CGImageP12CGColorSpacejd
9	QuartzCore	0x3287997c	-[CALayer(CALayerPrivate) _copyRenderLayer:layerFlags:commitFlags:]
10	QuartzCore	0x32879790	_ZN2CA5Layer17copy_render_layerEPNS_11TransactionEjPj
11	QuartzCore	0x32879726	_ZN2CA7Context12commit_layerEPNS_5LayerEjjPv
12	QuartzCore	0x328766fa	_ZN2CA5Layer16commit_if_neededEPNS_11TransactionEPFvPS0_jjPvES4_
13	QuartzCore	0x32876698	_ZN2CA5Layer16commit_if_neededEPNS_11TransactionEPFvPS0_jjPvES4_
14	QuartzCore	0x32876698	_ZN2CA5Layer16commit_if_neededEPNS_11TransactionEPFvPS0_jjPvES4_
15	QuartzCore	0x32876698	_ZN2CA5Layer16commit_if_neededEPNS_11TransactionEPFvPS0_jjPvES4_
16	QuartzCore	0x32876698	_ZN2CA5Layer16commit_if_neededEPNS_11TransactionEPFvPS0_jjPvES4_
17	QuartzCore	0x32876698	_ZN2CA5Layer16commit_if_neededEPNS_11TransactionEPFvPS0_jjPvES4_
18	QuartzCore	0x32876698	_ZN2CA5Layer16commit_if_neededEPNS_11TransactionEPFvPS0_jjPvES4_
19	QuartzCore	0x32876698	_ZN2CA5Layer16commit_if_neededEPNS_11TransactionEPFvPS0_jjPvES4_
20	QuartzCore	0x32874a14	_ZN2CA7Context18commit_transactionEPNS_11TransactionE
21	QuartzCore	0x328744ee	_ZN2CA11Transaction6commitEv
22	UIKit	0x32e5cb00	_UIWindowUpdateVisibleContextOrder
23	UIKit	0x32e5c994	+[UIWindow _prepareWindowsPassingTestForAppResume:]
24	UIKit	0x32e01d84	-[UIApplication _handleApplicationResumeEvent:]
25	UIKit	0x32c01084	-[UIApplication handleEvent:withNewEvent:]
26	UIKit	0x32c00870	-[UIApplication sendEvent:]
27	UIKit	0x32c64cc8	_UIApplicationHandleEvent
28	GraphicsServices	0x3526daec	_PurpleEventCallback
29	GraphicsServices	0x3526d6d6	PurpleEventCallback
30	CoreFoundation	0x303aaab6	__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
31	CoreFoundation	0x303aaa52	__CFRunLoopDoSource1
32	CoreFoundation	0x303a9226	__CFRunLoopRun
33	CoreFoundation	0x30313f4e	CFRunLoopRunSpecific
34	CoreFoundation	0x30313d32	CFRunLoopRunInMode
35	GraphicsServices	0x3526c662	GSEventRunModal
36	UIKit	0x32c5f16c	UIApplicationMain
37	FlightScheduleProPilotiPhone	0x00338d63	(wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain in Array.cs on Line 159
38	FlightScheduleProPilotiPhone	0x002fd773	MonoTouch.UIKit.UIApplication:Main in .pmcs-compat.UIApplication.cs on Line 75
39	FlightScheduleProPilotiPhone	0x001fd3cf	FlightSchedulePro.Pilot.iPhone.Application:Main in on Line 1
40	FlightScheduleProPilotiPhone	0x004bfb6f	wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
41	FlightScheduleProPilotiPhone	0x0092ef44	mono_jit_runtime_invoke in mini.c on Line 6610
42	FlightScheduleProPilotiPhone	0x009786a8	mono_runtime_invoke in object.c on Line 2827
43	FlightScheduleProPilotiPhone	0x0097c48a	mono_runtime_exec_main in object.c on Line 4052
44	FlightScheduleProPilotiPhone	0x0097c2ca	mono_runtime_run_main in object.c on Line 3678
45	FlightScheduleProPilotiPhone	0x00918b44	mono_jit_exec in driver.g.c on Line 1009
46	FlightScheduleProPilotiPhone	0x009d9b43	main in main.m on Line 489
47	libdyld.dylib	0x3b163ab6	start
//* End Stack Trace 1 *//

//* Start Stack Trace 2 *//
#	Binary Image Name	Address	Symbol
0	FlightScheduleProPilotiPhone	0x000e2bd0	testflight_backtrace
1	FlightScheduleProPilotiPhone	0x000e2488	TFSignalHandler
2	libsystem_platform.dylib	0x3b27df92	_sigtramp
3	libsystem_kernel.dylib	0x3b206858	mach_msg
4	SpringBoardServices	0x374e2bbe	SBAppWillOrderInContextForDisplay
5	UIKit	0x32c0458c	-[UIWindow _createContext]
6	UIKit	0x32e5cae0	_UIWindowUpdateVisibleContextOrder
7	UIKit	0x32e5c994	+[UIWindow _prepareWindowsPassingTestForAppResume:]
8	UIKit	0x32e01d84	-[UIApplication _handleApplicationResumeEvent:]
9	UIKit	0x32c01084	-[UIApplication handleEvent:withNewEvent:]
10	UIKit	0x32c00870	-[UIApplication sendEvent:]
11	UIKit	0x32c64cc8	_UIApplicationHandleEvent
12	GraphicsServices	0x3526daec	_PurpleEventCallback
13	GraphicsServices	0x3526d6d6	PurpleEventCallback
14	CoreFoundation	0x303aaab6	__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
15	CoreFoundation	0x303aaa52	__CFRunLoopDoSource1
16	CoreFoundation	0x303a9226	__CFRunLoopRun
17	CoreFoundation	0x30313f4e	CFRunLoopRunSpecific
18	CoreFoundation	0x30313d32	CFRunLoopRunInMode
19	GraphicsServices	0x3526c662	GSEventRunModal
20	UIKit	0x32c5f16c	UIApplicationMain
21	FlightScheduleProPilotiPhone	0x0033ad63	(wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain in Array.cs on Line 159
22	FlightScheduleProPilotiPhone	0x002ff773	MonoTouch.UIKit.UIApplication:Main in .pmcs-compat.UIApplication.cs on Line 75
23	FlightScheduleProPilotiPhone	0x001ff3cf	FlightSchedulePro.Pilot.iPhone.Application:Main in on Line 1
24	FlightScheduleProPilotiPhone	0x004c1b6f	wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
25	FlightScheduleProPilotiPhone	0x00930f44	mono_jit_runtime_invoke in mini.c on Line 6610
26	FlightScheduleProPilotiPhone	0x0097a6a8	mono_runtime_invoke in object.c on Line 2827
27	FlightScheduleProPilotiPhone	0x0097e48a	mono_runtime_exec_main in object.c on Line 4052
28	FlightScheduleProPilotiPhone	0x0097e2ca	mono_runtime_run_main in object.c on Line 3678
29	FlightScheduleProPilotiPhone	0x0091ab44	mono_jit_exec in driver.g.c on Line 1009
30	FlightScheduleProPilotiPhone	0x009dbb43	main in main.m on Line 489
31	libdyld.dylib	0x3b163ab6	start
//* End Stack Trace 2 *//
Comment 1 Rolf Bjarne Kvinge [MSFT] 2014-04-21 11:10:36 UTC
It looks like the symbolication for managed frames is a bit off for release builds (UIApplicationMain is not in Array.cs).

In any case that's just the top-most managed frame, and not the one responsible for the crash. You need to start at the top, from the _sigtramp frame, and then go down, trying to find something that makes sense.

In the first stack trace you'll see this:

2    libsystem_platform.dylib    0x3b27df92    _sigtramp
3    vImage    0x2f3ce26c    vPermuteChannels_ARGB8888
4    ImageIO    0x3112b154    copyImageBlockSetPNG

which suggests that the app was doing image manipulation in native code. If you look further up, you'll notice this (in both stack traces):

     UIKit    0x32e5c994    +[UIWindow _prepareWindowsPassingTestForAppResume:]

which indicates that the crash occurred when the app resumed.

My guess is that your app was backgrounded, some other app started using memory, then your app got a memory warning, iOS freed something you didn't expect to be freed in your app, and when your app tried to come back from the background it attempted to use the freed memory, causing a crash.

I'm closing this bug report since I can't see that this is a problem in Xamarin.iOS - but if you have a reproducible test case or any other information we'll be happy to look at it (just reopen the bug report and attach the information you have).
Comment 2 Jamie Mellway 2014-05-08 15:20:59 UTC
I also get this crash after I updated Xamarin.iOS.  I upgraded to 7.2.2.2 and I needed to add the "--registrar:legacy" mtouch argument.  It works fine in Debug on my iPad, but it crashes every time after 3:14 seconds when deploying from TestFlight.  I got someone else who still has Xamarin.iOS 7.0.5.2 installed to deploy (after removing the mtouch argument) and that release build is stable.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2014-05-08 16:22:56 UTC
@Jamie, it's unlikely you're running into the exact same issue as the reporter of this bug, so could you open a new one, and attach any crash reports and/or your project so that we can have a look at it?