MonoTouch random crash on device, not on simulator - ios

I am thinking this is somehow memory related, but I have done everything I can think of. I have made sure classes are disposed property. Maintained hard references at the class level instead of function scope, for things that might be getting GC'd while I am using them, etc.
Basically the app works fine in the simulator, but crashes at the same spot on a real device. Seems like I get a few different stacks, but they are all around the same place.
I am using a large amount of events in my application. Too many threads?
Stacktrace:
at Newtonsoft.Json.JsonWriter.WriteValue (object) at
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue
(Newtonsoft.Json.JsonWriter,object,Newtonsoft.Json.Serialization.JsonContract,Newtonsoft.Json.Serialization.JsonProperty,Newtonsoft.Json.Serialization.JsonContract)
at
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.WriteMemberInfoProperty
(Newtonsoft.Json.JsonWriter,object,Newtonsoft.Json.Serialization.JsonProperty,Newtonsoft.Json.Serialization.JsonContract)
at
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject
(Newtonsoft.Json.JsonWriter,object,Newtonsoft.Json.Serialization.JsonObjectContract,Newtonsoft.Json.Serialization.JsonProperty,Newtonsoft.Json.Serialization.JsonContract)
at
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue
(Newtonsoft.Json.JsonWriter,object,Newtonsoft.Json.Serialization.JsonContract,Newtonsoft.Json.Serialization.JsonProperty,Newtonsoft.Json.Serialization.JsonContract)
at
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList
(Newtonsoft.Json.JsonWriter,Newtonsoft.Json.Utilities.IWrappedCollection,Newtonsoft.Json.Serialization.JsonArrayContract,Newtonsoft.Json.Serialization.JsonProperty,Newtonsoft.Json.Serialization.JsonContract)
at
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue
(Newtonsoft.Json.JsonWriter,object,Newtonsoft.Json.Serialization.JsonContract,Newtonsoft.Json.Serialization.JsonProperty,Newtonsoft.Json.Serialization.JsonContract)
at
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.WriteMemberInfoProperty
(Newtonsoft.Json.JsonWriter,object,Newtonsoft.Json.Serialization.JsonProperty,Newtonsoft.Json.Serialization.JsonContract)
at
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject
(Newtonsoft.Json.JsonWriter,object,Newtonsoft.Json.Serialization.JsonObjectContract,Newtonsoft.Json.Serialization.JsonProperty,Newtonsoft.Json.Serialization.JsonContract)
at
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue
(Newtonsoft.Json.JsonWriter,object,Newtonsoft.Json.Serialization.JsonContract,Newtonsoft.Json.Serialization.JsonProperty,Newtonsoft.Json.Serialization.JsonContract)
at
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize
(Newtonsoft.Json.JsonWriter,object) at
Newtonsoft.Json.JsonSerializer.SerializeInternal
(Newtonsoft.Json.JsonWriter,object) at
Newtonsoft.Json.JsonSerializer.Serialize
(Newtonsoft.Json.JsonWriter,object) at
RestSharp.Serializers.JsonSerializer.Serialize (object) [0x0001c] in
/Users/sonmez56/Projects/TrackAbout.Mono/RestSharp/RestSharp/Serializers/JsonSerializer.cs:64
at RestSharp.RestRequest.AddBody (object,string) [0x00019] in
/Users/sonmez56/Projects/TrackAbout.Mono/RestSharp/RestSharp/RestRequest.cs:203
at RestSharp.RestRequest.AddBody (object) [0x00000] in
/Users/sonmez56/Projects/TrackAbout.Mono/RestSharp/RestSharp/RestRequest.cs:232
at
TrackAboutMonoCore.Services.TrackAboutAPIRequestBuilder/TARestRequest.WithBody
(T) <0x00097> at
TrackAboutMonoCore.Services.ActionsService.CustomerSetVolume
(int,System.Collections.Generic.List1<TrackAboutMonoCore.Models.Asset>,System.Action1>)
[0x00000] in
/Users/sonmez56/Projects/TrackAbout.Mono/TrackAboutMonoCore/Services/ActionsService.cs:24
at TrackAboutMonoCore.Controllers.LocateController.Save
(object,System.EventArgs) [0x00055] in
/Users/sonmez56/Projects/TrackAbout.Mono/TrackAboutMonoCore/Controllers/LocateController.cs:64
at MonoTouch.UIKit.UIBarButtonItem/Callback.Call
(MonoTouch.Foundation.NSObject) [0x00010] in
/Developer/MonoTouch/Source/monotouch/src/UIKit/UIBarButtonItem.cs:23
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 TrackAboutIOS.Application.Main (string[]) [0x00000] in
/Users/sonmez56/Projects/TrackAbout.Mono/TrackAboutIOS/TrackAboutIOS/Main.cs:16
at (wrapper runtime-invoke) object.runtime_invoke_dynamic
(intptr,intptr,intptr,intptr) <0xffffffff>
Native stacktrace:
0 TrackAboutIOS 0x01d20618
mono_handle_native_sigsegv + 280 1 TrackAboutIOS
0x01d45bd4 sigabrt_signal_handler + 180 2 libsystem_c.dylib
0x376647ed _sigtramp + 48 3 libsystem_c.dylib
0x3765a20f pthread_kill + 54 4 libsystem_c.dylib
0x3765329f abort + 94 5 TrackAboutIOS
0x01e394ac monoeg_g_log + 208 6 TrackAboutIOS
0x01d11664 get_numerous_trampoline + 160 7 TrackAboutIOS
0x01d11aac mono_aot_get_imt_thunk + 56 8 TrackAboutIOS
0x01dbdc50 initialize_imt_slot + 112 9 TrackAboutIOS
0x01dbf1c4 build_imt_slots + 1124 10 TrackAboutIOS
0x01dbf32c mono_vtable_build_imt_slot + 120 11 TrackAboutIOS
0x01d236fc mono_convert_imt_slot_to_vtable_slot + 292 12
TrackAboutIOS 0x01d23974 common_call_trampoline
+ 284 13 TrackAboutIOS 0x01d21c60 mono_vcall_trampoline + 228 14 TrackAboutIOS
0x00934198 generic_trampoline_vcall + 136 15 TrackAboutIOS
0x00b9fec4
Newtonsoft_Json_Serialization_JsonSerializerInternalWriter_SerializeValue_Newtonsoft_Json_JsonWriter_object_Newtonsoft_Json_Serialization_JsonContract_Newtonsoft_Json_Serialization_JsonProperty_Newtonsoft_Json_Serialization_JsonContract + 1116 16 TrackAboutIOS 0x00ba13bc Newtonsoft_Json_Serialization_JsonSerializerInternalWriter_WriteMemberInfoProperty_Newtonsoft_Json_JsonWriter_object_Newtonsoft_Json_Serialization_JsonProperty_Newtonsoft_Json_Serialization_JsonContract + 1712 17 TrackAboutIOS 0x00ba2a70 Newtonsoft_Json_Serialization_JsonSerializerInternalWriter_SerializeObject_Newtonsoft_Json_JsonWriter_object_Newtonsoft_Json_Serialization_JsonObjectContract_Newtonsoft_Json_Serialization_JsonProperty_Newtonsoft_Json_Serialization_JsonContract + 1784 18 TrackAboutIOS 0x00ba0124 Newtonsoft_Json_Serialization_JsonSerializerInternalWriter_SerializeValue_Newtonsoft_Json_JsonWriter_object_Newtonsoft_Json_Serialization_JsonContract_Newtonsoft_Json_Serialization_JsonProperty_Newtonsoft_Json_Serialization_JsonContract + 1724 19 TrackAboutIOS 0x00ba3ec0 Newtonsoft_Json_Serialization_JsonSerializerInternalWriter_SerializeList_Newtonsoft_Json_JsonWriter_Newtonsoft_Json_Utilities_IWrappedCollection_Newtonsoft_Json_Serialization_JsonArrayContract_Newtonsoft_Json_Serialization_JsonProperty_Newtonsoft_Json_Serialization_JsonContract + 2520 20 TrackAboutIOS 0x00ba041c Newtonsoft_Json_Serialization_JsonSerializerInternalWriter_SerializeValue_Newtonsoft_Json_JsonWriter_object_Newtonsoft_Json_Serialization_JsonContract_Newtonsoft_Json_Serialization_JsonProperty_Newtonsoft_Json_Serialization_JsonContract + 2484 21 TrackAboutIOS 0x00ba13bc Newtonsoft_Json_Serialization_JsonSerializerInternalWriter_WriteMemberInfoProperty_Newtonsoft_Json_JsonWriter_object_Newtonsoft_Json_Serialization_JsonProperty_Newtonsoft_Json_Serialization_JsonContract + 1712 22 TrackAboutIOS 0x00ba2a70 Newtonsoft_Json_Serialization_JsonSerializerInternalWriter_SerializeObject_Newtonsoft_Json_JsonWriter_object_Newtonsoft_Json_Serialization_JsonObjectContract_Newtonsoft_Json_Serialization_JsonProperty_Newtonsoft_Json_Serialization_JsonContract + 1784 23 TrackAboutIOS 0x00ba0124 Newtonsoft_Json_Serialization_JsonSerializerInternalWriter_SerializeValue_Newtonsoft_Json_JsonWriter_object_Newtonsoft_Json_Serialization_JsonContract_Newtonsoft_Json_Serialization_JsonProperty_Newtonsoft_Json_Serialization_JsonContract + 1724 24 TrackAboutIOS 0x00b9f70c Newtonsoft_Json_Serialization_JsonSerializerInternalWriter_Serialize_Newtonsoft_Json_JsonWriter_object
+ 356 25 TrackAboutIOS 0x00b2c52c Newtonsoft_Json_JsonSerializer_SerializeInternal_Newtonsoft_Json_JsonWriter_object
+ 300 26 TrackAboutIOS 0x00b2c3b4 Newtonsoft_Json_JsonSerializer_Serialize_Newtonsoft_Json_JsonWriter_object
+ 156 27 TrackAboutIOS 0x012010c0 RestSharp_Serializers_JsonSerializer_Serialize_object + 452 28
TrackAboutIOS 0x011f8ad0
RestSharp_RestRequest_AddBody_object_string + 396 29 TrackAboutIOS
0x011f8e4c RestSharp_RestRequest_AddBody_object + 152 30
TrackAboutIOS 0x011d3c64
TrackAboutMonoCore_Services_TrackAboutAPIRequestBuilder_TARestRequest_WithBody_T_T
+ 152 31 TrackAboutIOS 0x011d22d4 TrackAboutMonoCore_Services_ActionsService_CustomerSetVolume_int_System_Collections_Generic_List_1_TrackAboutMonoCore_Models_Asset_System_Action_1_RestSharp_RestResponse_1_TrackAbout_Rest_Models_TARestResponse
+ 328 32 TrackAboutIOS 0x011ce3bc TrackAboutMonoCore_Controllers_LocateController_Save_object_System_EventArgs
+ 960 33 TrackAboutIOS 0x0139003c MonoTouch_UIKit_UIBarButtonItem_Callback_Call_MonoTouch_Foundation_NSObject
+ 96 34 TrackAboutIOS 0x008b0450 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
+ 200 35 TrackAboutIOS 0x01d05834 mono_jit_runtime_invoke + 1644 36 TrackAboutIOS
0x01dbd09c mono_runtime_invoke + 128 37 TrackAboutIOS
0x01e4c054 monotouch_trampoline + 3436 38 CoreFoundation
0x30c7f3fd -[NSObject performSelector:withObject:withObject:] + 52 39
UIKit 0x3353efaf -[UIApplication
sendAction:to:from:forEvent:] + 62 40 UIKit
0x3360476b -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 118
41 CoreFoundation 0x30c7f3fd -[NSObject
performSelector:withObject:withObject:] + 52 42 UIKit
0x3353efaf -[UIApplication sendAction:to:from:forEvent:] + 62 43
UIKit 0x3353ef6b -[UIApplication
sendAction:toTarget:fromSender:forEvent:] + 30 44 UIKit
0x3353ef49 -[UIControl sendAction:to:forEvent:] + 44 45 UIKit
0x3353ecb9 -[UIControl(Internal) _sendActionsForEvents:withEvent:] +
492 46 UIKit 0x3353f5f1 -[UIControl
touchesEnded:withEvent:] + 476 47 UIKit
0x3353dad3 -[UIWindow _sendTouchesForEvent:] + 318 48 UIKit
0x3353d4c1 -[UIWindow sendEvent:] + 380 49 UIKit
0x3352383d -[UIApplication sendEvent:] + 356 50 UIKit
0x335230e3 _UIApplicationHandleEvent + 5826 51 GraphicsServices
0x33e1322b PurpleEventCallback + 882 52 CoreFoundation
0x30cf9523 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION
+ 38 53 CoreFoundation 0x30cf94c5 CFRunLoopDoSource1 + 140 54 CoreFoundation 0x30cf8313 __CFRunLoopRun + 1370 55 CoreFoundation
0x30c7b4a5 CFRunLoopRunSpecific + 300 56 CoreFoundation
0x30c7b36d CFRunLoopRunInMode + 104 57 GraphicsServices
0x33e12439 GSEventRunModal + 136 58 UIKit
0x33551e7d UIApplicationMain + 1080 59 TrackAboutIOS
0x01696c74
wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string_intptr_intptr
+ 240 60 TrackAboutIOS 0x00098420 TrackAboutIOS_Application_Main_string__ + 152 61 TrackAboutIOS
0x008b0450
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
+ 200 62 TrackAboutIOS 0x01d05834 mono_jit_runtime_invoke + 1644 63 TrackAboutIOS
0x01dbd09c mono_runtime_invoke + 128 64 TrackAboutIOS
0x01dc16b4 mono_runtime_exec_main + 436 65 TrackAboutIOS
0x01dc1a74 mono_runtime_run_main + 756 66 TrackAboutIOS
0x01d0c744 mono_jit_exec + 140 67 TrackAboutIOS
0x01e41110 main + 2288 68 TrackAboutIOS
0x0009826c start + 52

There's normally an exception type and message before the line:
Stacktrace:
It usually provides a good hint of the issue. Now the native stack trace also gives a clue here:
0x01e394ac monoeg_g_log + 208 6 TrackAboutIOS
0x01d11664 get_numerous_trampoline + 160 7 TrackAboutIOS
The first line tells us something was printed (or at least it tried to print) in your logs. It you check your device's log (e.g. using Xcode or mtouch --logdev) you should see the message.
The next line makes me think you're running out of trampolines (the error message will tell you which type). Here are the instructions on how to augment the number of trampolines available for your application.
Note: in case this is not trampoline-related please edit your question to add the exception type/message and the content of your device's log.

Related

iOS crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000

I have received some crashes via Crashlytics. It crashed 4 times in last month.
I use Masonry for autolayout and add constraint in layoutSubviews. You can see the crash trace below.
0 libsystem_platform.dylib _platform_memmove + 284
1 Foundation _NSBitSetResize.llvm.9545202549352731061 + 288
2 Foundation NSBitSetAddIndex + 52
3 Foundation NSISLinExpEnumerateVars + 88
4 Foundation _row_setHead + 156
5 Foundation -[NSISEngine tryAddingDirectly:] + 236
6 Foundation -[NSISEngine _tryToAddConstraintWithMarkerEngineVar:row:mutuallyExclusiveConstraints:] + 156
7 Foundation -[NSISEngine tryToAddConstraintWithMarker:expression:mutuallyExclusiveConstraints:] + 684
8 Foundation -[NSLayoutConstraint _addLoweredExpression:toEngine:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:] + 252
9 Foundation -[NSLayoutConstraint _addToEngine:mutuallyExclusiveConstraints:] + 188
10 UIKitCore -[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 548
11 UIKitCore -[UIView(UIConstraintBasedLayout) _tryToAddConstraintWithoutUpdatingConstraintsArray:roundingAdjustment:mutuallyExclusiveConstraints:] + 36
12 UIKitCore -[UIView(UIConstraintBasedLayout) nsli_addConstraint:] + 84
13 ChopeDashboard MASViewConstraint.m line 361 -[MASViewConstraint install] + 361
14 ChopeDashboard MASConstraintMaker.m line 46 -[MASConstraintMaker install] + 46
15 ChopeDashboard View+MASAdditions.m line 18 -[UIView(MASAdditions) mas_makeConstraints:] + 18
16 ChopeDashboard CDResListHeaderView.m line 128 -[CDResListHeaderView layoutSubviews] + 128
17 UIKitCore -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2140
18 QuartzCore -[CALayer layoutSublayers] + 284
19 QuartzCore CA::Layer::layout_if_needed(CA::Transaction*) + 480
20 QuartzCore CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 136
21 QuartzCore CA::Context::commit_transaction(CA::Transaction*, double) + 304
22 QuartzCore CA::Transaction::commit() + 676
23 QuartzCore CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 888
24 IOKit IODispatchCalloutFromCFMessage + 488
25 CoreFoundation __CFMachPortPerform + 172
26 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
27 CoreFoundation __CFRunLoopDoSource1 + 444
28 CoreFoundation __CFRunLoopRun + 2168
29 CoreFoundation CFRunLoopRunSpecific + 464
30 GraphicsServices GSEventRunModal + 104
31 UIKitCore UIApplicationMain + 1936
32 ChopeDashboard main.m line 14 main + 14
33 libdyld.dylib start + 4
Has anyone faced the same issue?

my app crash in uikit ,only happen on IPhone X and above exception name NSInternalInconsistencyException

Failed to load bounding path bitmap data from the asset manager for asset name: BoundingPathBitmap-1125x2436-375x812-3.00x
The crash happen on the viewcontroller contain UIScrollView When open it,and only happens with the iPhone X and above
We develop app UI use storyboard
0 CoreFoundation ___exceptionPreprocess + 228
1 libobjc.A.dylib objc_exception_throw + 56
2 CoreFoundation +[_CFXNotificationTokenRegistration keyCallbacks]
3 Foundation -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 112
4 UIKitCore -[_UIScreenBezierBoundingPathUtilities _loadBitmapForScreen:type:] + 1124
5 UIKitCore -[_UIScreenBezierBoundingPathUtilities initWithScreen:] + 144
6 UIKitCore +[_UIScreenBoundingPathUtilities boundingPathUtilitiesForScreen:] + 108
7 UIKitCore -[UIScreen _boundingPathUtilities] + 56
8 UIKitCore -[UIWindow _boundingPath] + 168
9 UIKitCore -[UIView(UIViewBoundingPathSupportInternal) _effectiveBoundingPathAndBoundingPathView:] + 256
10 UIKitCore -[UIView(UIViewBoundingPathSupport) _inscribedRectInBoundingPathByInsettingRect:onEdges:withOptions:] + 88
11 UIKitCore -[UIScrollView(UIScrollViewInternal) _baseInsetsForTrailingEdgeAccessoryWithBoundingPathEdgesToUse:safeAreaInsets:bounds:scale:accessoryWidth:additionalInsetFromEdge:] + 180
12 UIKitCore -[UIScrollView(UIScrollViewInternal) _baseInsetsForAccessoryOnEdge:hasCustomClientInsets:accessorySize:additionalInsetFromEdge:] + 1388
13 UIKitCore -[UIScrollView(UIScrollViewInternal) _effectiveVerticalScrollIndicatorInsets] + 152
14 UIKitCore -[UIScrollView _layoutVerticalScrollIndicatorWithBounds:effectiveInset:contentOffset:fraction:additionalInset:cornerAdjust:showing:recalcSize:] + 252
15 UIKitCore -[UIScrollView _adjustScrollerIndicators:alwaysShowingThem:] + 1040
16 UIKitCore -[UIScrollView _updateForChangedScrollIndicatorRelatedInsets] + 132
17 UIKitCore __UIScrollViewAdjustForOverlayInsetsChangeIfNecessary + 512
18 UIKitCore -[UIScrollView(UIScrollViewInternal) setSafeAreaInsets:] + 312
19 UIKitCore -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:] + 1288
20 UIKitCore -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 124
21 UIKitCore -[UIScrollView(_UIOldConstraintBasedLayoutSupport) _resizeWithOldSuperviewSize:] + 52
22 CoreFoundation -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 464
23 UIKitCore -[UIView(Geometry) resizeSubviewsWithOldSize:] + 156
24 UIKitCore -[UIView(AdditionalLayoutSupport) _is_layout] + 152
25 UIKitCore -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 988
26 UIKitCore -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1380
27 QuartzCore 0x00000001ca79e000 + 1309564
28 QuartzCore 0x00000001ca79e000 + 1329972
29 QuartzCore 0x00000001ca79e000 + 669080
30 QuartzCore 0x00000001ca79e000 + 859848
31 QuartzCore 0x00000001ca79e000 + 863536
32 CoreFoundation ___CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
33 CoreFoundation ___CFRunLoopDoObservers + 412
34 CoreFoundation ___CFRunLoopRun + 1264
35 CoreFoundation CFRunLoopRunSpecific + 436
36 GraphicsServices GSEventRunModal + 100
37 UIKitCore UIApplicationMain + 212
38 live main (main.mm:23)
39 libdyld.dylib 0x00000001c5d2a000 + 2996
hope someone could give me some advice, thanks
The same crash also happened in my app.
When I turned off the 'Show Horizontal Indicator' and 'Show Vertical Indicator' on the storyboard, the crash no longer occurred.
It just happened with my app .. Fixed ,
Delete the app and restart Simulator ..
^ command + shift + K to clean build folder

Random crash on setting UITabBarButton label attributed text (Tab Title)

I am not able to reproduce this crash but received this kind of crashes multiple times from production build. In my app tab bar is loaded from storyboard only and tab bar is always hidden all the time.
Does it's main cause is low memory? Any guess, how to solve or reproduce this kind of problems
Hardware Model: iPad2,4
OS Version: iPhone OS 7.0.4 (11B554a)
Report Version: 104
Exception Type: SIGABRT
Exception Codes: #0 at 0x393f71fc
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds'
Last Exception Backtrace:
0 CoreFoundation 0x2e766f4b __exceptionPreprocess + 131
1 libobjc.A.dylib 0x38e386af objc_exception_throw + 38
2 CoreFoundation 0x2e766e8d +[NSException raise:format:] + 104
3 Foundation 0x2f089aff -[NSMutableRLEArray replaceObjectsInRange:withObject:length:] + 122
4 Foundation 0x2f088efb -[NSConcreteMutableAttributedString initWithString:attributes:] + 310
5 UIKit 0x30ee8ed7 -[NSAttributedString(UILabelAdditions) _ui_synthesizeAttributedSubstringFromRange:usingDefaultAttributes:] + 86
6 UIKit 0x30ee8c9f -[UILabel _synthesizedAttributedText] + 1010
7 UIKit 0x30ee8307 -[UILabel _textRectForBounds:limitedToNumberOfLines:includingShadow:] + 222
8 UIKit 0x30ee8213 -[UILabel textRectForBounds:limitedToNumberOfLines:] + 54
9 UIKit 0x30ee80fb -[UILabel _intrinsicSizeWithinSize:] + 162
10 UIKit 0x30ee8049 -[UILabel sizeThatFits:] + 32
11 UIKit 0x30ee7f37 -[UIView(Geometry) sizeToFit] + 126
12 UIKit 0x31002be1 -[UITabBarButton initWithImage:selectedImage:label:withInsets:] + 388
13 UIKit 0x31001a1f -[UITabBarItem(Static) _createViewForTabBar:showingBadge:withTint:idiom:] + 1170
14 UIKit 0x31001583 -[UITabBarItem(Static) _createViewForTabBar:showingBadge:idiom:] + 38
15 UIKit 0x30ffd859 -[UITabBarItem(Static) _updateViewForIdiom:positionItems:] + 160
16 UIKit 0x31004c43 -[UITabBar(Static) _configureItems:] + 406
17 UIKit 0x310042db -[UITabBar(Static) _positionTabBarButtons:ignoringItem:] + 1234
18 UIKit 0x3100133f -[UITabBar setItems:animated:] + 1358
19 UIKit 0x31000d29 -[UITabBarController _rebuildTabBarItemsAnimated:] + 800
20 UIKit 0x310051f9 -[UITabBarController _setSelectedViewController:] + 76
21 UIKit 0x30eeb6e5 +[UIView(Animation) performWithoutAnimation:] + 72
22 UIKit 0x31008bf7 -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 218
23 UIKit 0x31008077 -[UITabBarController viewWillAppear:] + 134
24 UIKit 0x30ef40eb -[UIViewController _setViewAppearState:isAnimating:] + 346
25 CoreFoundation 0x2e6aff65 __53-[__NSArrayI enumerateObjectsWithOptions:usingBlock:]_block_invoke + 52
26 CoreFoundation 0x2e6a994d -[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 220
27 UIKit 0x30ef4265 -[UIViewController _setViewAppearState:isAnimating:] + 724
28 UIKit 0x3106a4bf -[UINavigationController _startCustomTransition:] + 846
29 UIKit 0x30f88273 -[UINavigationController _startDeferredTransitionIfNeeded:] + 418
30 UIKit 0x30f8807d -[UINavigationController __viewWillLayoutSubviews] + 44
31 UIKit 0x30f88015 -[UILayoutContainerView layoutSubviews] + 184
32 UIKit 0x30ed9da3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 346
33 QuartzCore 0x30b60c6b -[CALayer layoutSublayers] + 142
34 QuartzCore 0x30b5c47b CA::Layer::layout_if_needed(CA::Transaction*) + 350
35 QuartzCore 0x30b5c30d CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
36 QuartzCore 0x30b5bd1f CA::Context::commit_transaction(CA::Transaction*) + 230
37 QuartzCore 0x30b5bb2f CA::Transaction::commit() + 314
38 QuartzCore 0x30b5585d CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 56
39 CoreFoundation 0x2e7321cd __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
40 CoreFoundation 0x2e72fb71 __CFRunLoopDoObservers + 284
41 CoreFoundation 0x2e72feb3 __CFRunLoopRun + 730
42 CoreFoundation 0x2e69ac27 CFRunLoopRunSpecific + 522
43 CoreFoundation 0x2e69aa0b CFRunLoopRunInMode + 106
44 GraphicsServices 0x3336e283 GSEventRunModal + 138
45 UIKit 0x30f3e049 UIApplicationMain + 1136
46 MyApp main (in MyApp) (main.m:16)
47 libdyld.dylib 0x39340ab7 start + 2
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x393f71fc __pthread_kill + 8
1 libsystem_c.dylib 0x393a7ffd abort + 77
2 MyApp uncaught_exception_handler (in MyApp) + 27
3 CoreFoundation 0x2e76724f __handleUncaughtException + 579
4 libobjc.A.dylib 0x38e3890f _objc_terminate() + 175
5 libc++abi.dylib 0x386ed1c7 std::__terminate(void (*)()) + 79
6 libc++abi.dylib 0x386ecd2d __cxa_increment_exception_refcount + 1
7 libobjc.A.dylib 0x38e387f7 objc_exception_rethrow + 43
8 CoreFoundation 0x2e69ac9d CFRunLoopRunSpecific + 641
9 CoreFoundation 0x2e69aa0b CFRunLoopRunInMode + 106
10 GraphicsServices 0x3336e283 GSEventRunModal + 138
11 UIKit 0x30f3e049 UIApplicationMain + 1136
12 MyApp main (in MyApp) (main.m:16)
From you crash log, line 5
5 UIKit 0x30ee8ed7 -[NSAttributedString(UILabelAdditions) _ui_synthesizeAttributedSubstringFromRange:usingDefaultAttributes:] + 86
seems like you generate your attribute string based on
- (NSAttributedString *)attributedSubstringFromRange:(NSRange)aRange
Maybe set a break point at that code, and check if your string length is larger than or equal to the range.

Unable to find root cause of random crash on tabbar

I have a side panel view (like side drawer) in my iPad app which contains tabbar having 2 tabs. This view is beyond the ipad visible screen and become visible once we pull it from left side. This get initialize always on app launch. It crashes randomly on iOS 7.0.3 and 7.0.4 mostly on iPad 4 models. I can't reproduce it in debug mode while debugger is attached and reproducing frequency is 1% or less on release build.
It will not an iOS issue but any guess or anybody faced and solved similar problem?
Crash report:
Hardware Model: iPad3,4
Code Type: ARM (Native)
OS Version: iOS 7.0.4 (11B554a)
Crash report:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 12
Thread 0:
0 libsystem_kernel.dylib 0x38d7ebb4 syscall_thread_switch + 8
1 libsystem_platform.dylib 0x38df349c _os_lock_handoff_lock_slow + 48
2 libsystem_malloc.dylib 0x38db90f8 szone_free_definite_size + 328
3 libRIP.A.dylib 0x2e4ffb72 ripc_ReleaseClipState + 34
4 libRIP.A.dylib 0x2e503438 ripc_EndLayer + 80
5 CoreGraphics 0x2e1c25e8 CGContextEndTransparencyLayer + 36
6 UIKit 0x309e4d2a -[UIImage(TabBarItemImages) _tabBarItemImageWithTintColor:selected:metrics:style:forScreenScale:] + 902
7 UIKit 0x309e5070 -[UIImage(TabBarItemImages) _unselectedTabBarItemImageWithTintColor:metrics:style:forScreenScale:] + 36
8 UIKit 0x309e4748 -[UITabBarItem(Static) _updateImageWithTintColor:isSelected:getImageOffset:] + 552
9 UIKit 0x309e414c -[UITabBarItem(Static) _createViewForTabBar:showingBadge:withTint:idiom:] + 956
10 UIKit 0x309e3d82 -[UITabBarItem(Static) _createViewForTabBar:showingBadge:idiom:] + 34
11 UIKit 0x309e0028 -[UITabBarItem(Static) _updateViewForIdiom:positionItems:] + 156
12 UIKit 0x309e74ca -[UITabBar(Static) _configureItems:] + 402
13 UIKit 0x309e6b7e -[UITabBar(Static) _positionTabBarButtons:ignoringItem:] + 1270
14 UIKit 0x309e3b38 -[UITabBar setItems:animated:] + 1352
15 UIKit 0x309e3522 -[UITabBarController _rebuildTabBarItemsAnimated:] + 798
16 UIKit 0x309e7a74 -[UITabBarController _setSelectedViewController:] + 72
17 UIKit 0x308cdcf2 +[UIView(Animation) performWithoutAnimation:] + 70
18 UIKit 0x309eb470 -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 216
19 UIKit 0x309ea8e6 -[UITabBarController viewWillAppear:] + 130
20 UIKit 0x308d66fa -[UIViewController _setViewAppearState:isAnimating:] + 342
21 CoreFoundation 0x2e080800 __53-[__NSArrayI enumerateObjectsWithOptions:usingBlock:]_block_invoke + 48
22 CoreFoundation 0x2e07a21a -[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 218
23 UIKit 0x308d6876 -[UIViewController _setViewAppearState:isAnimating:] + 722
24 UIKit 0x30a4ccfa -[UINavigationController _startCustomTransition:] + 842
25 UIKit 0x3096aa12 -[UINavigationController _startDeferredTransitionIfNeeded:] + 414
26 UIKit 0x3096a81c -[UINavigationController __viewWillLayoutSubviews] + 40
27 UIKit 0x3096a7b4 -[UILayoutContainerView layoutSubviews] + 180
28 UIKit 0x308bc34e -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 342
29 QuartzCore 0x3054293e -[CALayer layoutSublayers] + 138
30 QuartzCore 0x3053e162 CA::Layer::layout_if_needed(CA::Transaction*) + 346
31 QuartzCore 0x3053dff4 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 12
32 QuartzCore 0x3053da08 CA::Context::commit_transaction(CA::Transaction*) + 224
33 QuartzCore 0x3053d81a CA::Transaction::commit() + 310
34 QuartzCore 0x30537548 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 52
35 CoreFoundation 0x2e102f66 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
36 CoreFoundation 0x2e1008f2 __CFRunLoopDoObservers + 282
37 CoreFoundation 0x2e100c3e __CFRunLoopRun + 734
38 CoreFoundation 0x2e06b46c CFRunLoopRunSpecific + 520
39 CoreFoundation 0x2e06b24e CFRunLoopRunInMode + 102
40 GraphicsServices 0x32d722e6 GSEventRunModal + 134
41 UIKit 0x30920840 UIApplicationMain + 1132
42 MyApp 0x0006b5f2 0x64000 + 30194
43 libdyld.dylib 0x38cdaab4 start + 0
Thread 12 Crashed:
0 libsystem_kernel.dylib 0x38d911fc __pthread_kill + 8
1 libsystem_pthread.dylib 0x38df8a4e pthread_kill + 54
2 libsystem_c.dylib 0x38d42082 __abort + 74
3 libsystem_c.dylib 0x38d42034 abort + 84
4 libsystem_malloc.dylib 0x38dbf758 szone_error + 312
5 libsystem_malloc.dylib 0x38dbf9d4 free_list_checksum_botch + 24
6 libsystem_malloc.dylib 0x38dba1a4 tiny_free_list_remove_ptr + 76
7 libsystem_malloc.dylib 0x38db9770 szone_free_definite_size + 1984
8 libsystem_blocks.dylib 0x38cf7ac2 _Block_release + 214
9 libdispatch.dylib 0x38ccae76 _dispatch_queue_drain + 370
10 libdispatch.dylib 0x38cc7f8e _dispatch_queue_invoke + 38
11 libdispatch.dylib 0x38ccb742 _dispatch_root_queue_drain + 74
12 libdispatch.dylib 0x38ccb9c0 _dispatch_worker_thread2 + 52
13 libsystem_pthread.dylib 0x38df5dfc _pthread_wqthread + 296
14 libsystem_pthread.dylib 0x38df5cc0 start_wqthread + 4
Another random crash in similar case:
Thread 0 Crashed:
0 CoreFoundation 0x311e9728 -[__NSDictionaryM objectForKey:] + 100
1 UIKit 0x33a3e855 -[UILabel _setFont:] + 209
2 UIKit 0x33b5a411 -[UITabBarButton initWithImage:selectedImage:label:withInsets:] + 293
3 UIKit 0x33b59223 -[UITabBarItem(Static) _createViewForTabBar:showingBadge:withTint:idiom:] + 1171
4 UIKit 0x33b58d87 -[UITabBarItem(Static) _createViewForTabBar:showingBadge:idiom:] + 39
5 UIKit 0x33b5502d -[UITabBarItem(Static) _updateViewForIdiom:positionItems:] + 161
6 UIKit 0x33b5c4cf -[UITabBar(Static) _configureItems:] + 407
7 UIKit 0x33b5bb83 -[UITabBar(Static) _positionTabBarButtons:ignoringItem:] + 1275
8 UIKit 0x33b58b3d -[UITabBar setItems:animated:] + 1357
9 UIKit 0x33b58527 -[UITabBarController _rebuildTabBarItemsAnimated:] + 803
10 UIKit 0x33b5ca79 -[UITabBarController _setSelectedViewController:] + 77
11 UIKit 0x33a42cf5 +[UIView(Animation) performWithoutAnimation:] + 73
12 UIKit 0x33b60475 -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 221
13 UIKit 0x33b5f8eb -[UITabBarController viewWillAppear:] + 135
14 UIKit 0x33a4b6ff -[UIViewController _setViewAppearState:isAnimating:] + 347
15 CoreFoundation 0x311f5803 __53-[__NSArrayI enumerateObjectsWithOptions:usingBlock:]_block_invoke + 51
16 CoreFoundation 0x311ef21d -[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 221
17 UIKit 0x33a4b87b -[UIViewController _setViewAppearState:isAnimating:] + 727
18 UIKit 0x33bc1cff -[UINavigationController _startCustomTransition:] + 847
19 UIKit 0x33adfa17 -[UINavigationController _startDeferredTransitionIfNeeded:] + 419
20 UIKit 0x33adf821 -[UINavigationController __viewWillLayoutSubviews] + 45
21 UIKit 0x33adf7b9 -[UILayoutContainerView layoutSubviews] + 185
22 UIKit 0x33a31353 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 347
23 QuartzCore 0x336b7943 -[CALayer layoutSublayers] + 143
24 QuartzCore 0x336b3167 CA::Layer::layout_if_needed(CA::Transaction*) + 351
25 QuartzCore 0x336b2ff9 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 17
26 QuartzCore 0x336b2a0d CA::Context::commit_transaction(CA::Transaction*) + 229
27 QuartzCore 0x336b281f CA::Transaction::commit() + 315
28 QuartzCore 0x336ac54d CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 57
29 CoreFoundation 0x31277f69 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 21
30 CoreFoundation 0x312758f7 __CFRunLoopDoObservers + 287
31 CoreFoundation 0x31275c43 __CFRunLoopRun + 739
32 CoreFoundation 0x311e0471 CFRunLoopRunSpecific + 525
33 CoreFoundation 0x311e0253 CFRunLoopRunInMode + 107
34 GraphicsServices 0x35ee12eb GSEventRunModal + 139
35 UIKit 0x33a95845 UIApplicationMain + 1137
36 SofTestM 0x000545f7 0x4d000 + 30199
The second crash is at time of setting font at
UITabBar-->UITabBarButton->UILabel (of UITabBarButton) _setFont:
I feel this random crashes might be due to memory leaks in your application.Pardon me if i am wrong.
In your logs it is seen that you use CoreGraphics.Releasing Core Graphics( even if you have ARC) is a bit tricky as it is not 100% memory leaf proof .That is it at times takes a while to get released.
So suppose you are using core graphic objects whithin a loop then it is certain that your ipad memory will go out of bounds.

Monotouch memory limitation crash

I have a question about monotouch app memory limitation.
I tried to stress my iPad memory with a very simple app that allocates 1MB arrays into a list. On each loop I display the number of loop. I notice my app crashing around 130 MB allocation.
My code:
List<byte[]> arrays = new List<byte[]>();
try
{
for (int i = 0; i < 1323; i++)
{
arrays.Add(new byte[1024 * 1024]);
Console.WriteLine("RAM: " + (i + 1) + " Mo");
}
}
catch { }
I don't understand why, on an iPad 3 or iPad 4, my app crashes around 130MB with following message:
Native stacktrace:
0 TestMemory 0x002687f9 mono_handle_native_sigsegv + 244
1 TestMemory 0x00295d75 sigabrt_signal_handler + 112
2 libsystem_c.dylib 0x35a75e93 _sigtramp + 42
3 libsystem_c.dylib 0x35a6c123 pthread_kill + 58
4 libsystem_c.dylib 0x35aa8973 abort + 94
5 TestMemory 0x0026353d GC_expand_hp_inner + 0
6 TestMemory 0x00263637 GC_expand_hp_inner + 250
7 TestMemory 0x00263aed GC_collect_or_expand + 128
8 TestMemory 0x00265d99 GC_alloc_large + 96
9 TestMemory 0x00265fe9 GC_generic_malloc + 180
10 TestMemory 0x00266185 GC_malloc_atomic + 112
11 TestMemory 0x0028c011 mono_array_new_specific + 124
12 TestMemory 0x00172e04 wrapper_managed_to_native_object___icall_wrapper_mono_array_new_specific_intptr_int + 68
13 TestMemory 0x0007305c MonoTouch_UIKit_UIControlEventProxy_Activated + 68
14 TestMemory 0x0016df50 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
15 TestMemory 0x002314e3 mono_jit_runtime_invoke + 1054
16 TestMemory 0x0028c8c3 mono_runtime_invoke + 90
17 TestMemory 0x0022b6f7 native_to_managed_trampoline_MonoTouch_UIKit_UIControlEventProxy_Activated + 178
18 UIKit 0x3ace40a5 <redacted> + 72
19 UIKit 0x3ace4057 <redacted> + 30
20 UIKit 0x3ace4035 <redacted> + 44
21 UIKit 0x3ace38eb <redacted> + 502
22 UIKit 0x3ace357b <redacted> + 242
23 UIKit 0x3ac0c523 <redacted> + 318
24 UIKit 0x3abf9801 <redacted> + 380
25 UIKit 0x3abf911b <redacted> + 6154
26 GraphicsServices 0x3637c5a3 <redacted> + 590
27 GraphicsServices 0x3637c1d3 <redacted> + 34
28 CoreFoundation 0x38856173 <redacted> + 34
29 CoreFoundation 0x38856117 <redacted> + 138
30 CoreFoundation 0x38854f99 <redacted> + 1384
31 CoreFoundation 0x387c7ebd CFRunLoopRunSpecific + 356
32 CoreFoundation 0x387c7d49 CFRunLoopRunInMode + 104
33 GraphicsServices 0x3637b2eb GSEventRunModal + 74
34 UIKit 0x3ac4d2f9 UIApplicationMain + 1120
35 TestMemory 0x0008b3c4 wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 240
36 TestMemory 0x00219bf0 TestMemory_Application_Main_string__ + 152
37 TestMemory 0x0016df50 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
38 TestMemory 0x002314e3 mono_jit_runtime_invoke + 1054
39 TestMemory 0x0028c8c3 mono_runtime_invoke + 90
40 TestMemory 0x0028f3a7 mono_runtime_exec_main + 306
41 TestMemory 0x0029262b mono_runtime_run_main + 482
42 TestMemory 0x00242ecf mono_jit_exec + 94
43 TestMemory 0x002cce3c main + 2220
44 TestMemory 0x00002028 start + 40
You crash because you use up all the memory iOS is willing to give you. This is not a MonoTouch limitation, it's an iOS limitation.

Resources