CrashReport from Hockey, awkward Stacktrace with NSPlaceholderDictionary - iphone

got some strange stack trace from an app i developed. here the stack trace:
Exception Type: SIGTRAP
Exception Codes: #0 at 0x312b1848
Crashed Thread: 0
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]:
attempt to insert nil object from objects[0]'
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x35c48848 __kill + 8
1 CoreFoundation 0x34dba957 __handleUncaughtException + 75
2 libobjc.A.dylib 0x361e1345 _objc_terminate + 129
3 libc++abi.dylib 0x000043c5 safe_handler_caller(void (*)()) + 77
4 libc++abi.dylib 0x00004451 operator delete(void*) + 1
5 libc++abi.dylib 0x00005825 __cxa_current_exception_type + 1
6 libobjc.A.dylib 0x361e12a9 objc_exception_rethrow + 13
7 CoreFoundation 0x34d1050d CFRunLoopRunSpecific + 405
8 CoreFoundation 0x34d1036d CFRunLoopRunInMode + 105
9 GraphicsServices 0x36f85439 GSEventRunModal + 137
10 UIKit 0x32df5cd5 UIApplicationMain + 1081
11 myApp 0x000073f9 main (main.m:42)
this happens when you click on a tableview and a view should be pushed on the navigation controller. i never get this bug reproduced, so i could not say precisely, when it happened.
it could be that only iOS 5.1.1 is affected (only crash reports from this version exists).
i always check objects before adding them to a dict, so could loading xibs be a reason for that? perhaps it is kind of damaged, i recognized that sometimes xibs are in a very strange way...
thanks for every help

If your crash reporter isn't reporting the exception backtrace, it needs to be fixed. Exceptions on the main thread have been caught and "re-thrown" (hence objc_exception_rethrow) since iOS 5 (nearly a year ago!).
I think __NSPlaceholderDictionary is just what you get by calling [NSDictionary alloc]. I suspect the culprit is code that does [NSDictionary dictionaryWithObject:x forKey:#"foo"] without checking that x is non-nil.
iTunes Connect's crash reporting may also be helpful, though they display a very small subset of actual crashes.

Related

How to fix 'outlined consume of Model?' runtime crash on Swift 5

I just upgraded one of my apps to Swift 5, I didn't change so much at all and there didn't seem to be any problems, so I just released it in production (fortunately in phased release).
After 1 days I started to see a very strange crash on Crashlytics that affect the 15% of people that is using my app.
This is the stack trace:
Crashed: com.apple.main-thread
0 (Missing) 0x31698aa1503e0 (Missing)
1 libswiftCore.dylib 0x1afa5ac68 _swift_release_dealloc + 28
2 App 0x104194c3c outlined consume of MyModel? + 4300033084
3 App 0x104482cb8 #objc MyController.__ivar_destroyer (<compiler-generated>)
4 libobjc.A.dylib 0x180f267cc object_cxxDestructFromClass(objc_object*, objc_class*) + 148
5 libobjc.A.dylib 0x180f366b8 objc_destructInstance + 68
6 libobjc.A.dylib 0x180f36720 object_dispose + 16
7 UIKitCore 0x1ae2edac0 -[UIResponder dealloc] + 152
8 UIKitCore 0x1add173e0 -[UIViewController dealloc] + 1748
9 App 0x10431d82c BaseViewController.__deallocating_deinit (MyController.swift:56)
10 App 0x10431d85c #objc BaseViewController.__deallocating_deinit (<compiler-generated>)
11 libobjc.A.dylib 0x180f41b9c (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 672
12 CoreFoundation 0x181d59f40 _CFAutoreleasePoolPop + 28
13 CoreFoundation 0x181cd8e00 __CFRunLoopRun + 1932
14 CoreFoundation 0x181cd8354 CFRunLoopRunSpecific + 436
15 GraphicsServices 0x183ed879c GSEventRunModal + 104
16 UIKitCore 0x1ae2c3b68 UIApplicationMain + 212
17 App 0x104108468 main (AppDelegate.swift:21)
18 libdyld.dylib 0x18179e8e0 start + 4
I searched already something on the web but I find only a thread on the Swift Forum not very related to this.
MyModel is actually a struct model that is nested into another Model.
MyController is the very huge controller that manages the model.
The crash seems to happen obviously when popping the controller and so when the System tries to deallocate all the related properties.
I tried to replicate it many times with no results, and I didn't know really where to start looking.
Someone had the same problem?
UPDATE [Partially Fixed]:
It seemed to be a stack corruption caused by a Advertising Framework, to fix this I moved MyModel from Struct to Class, it's now on the Heap and can't get double freed.
From my experience, most of the outlined consume of errors are caused by concurrency issue. When one queue/thread reading the struct while another queue/thread modifying it without synchronization (mutex, semaphore, barrier, etc).
You need to check all threads stacks to see which thread access MyModel simultaneously with the Main(crashed) thread.

How to read Xcode console output?

As a Java and PHP developer new to Xcode, I am having trouble dealing with memory errors. I have a sample program from a book, which crashes on startup with "Program received signal 'SIGABRT'." I don't know what to do with the console output below. I realize it's some kind of stack trace, but the name on the left is just the name of the application, not a class or file. I don't know what "main + 121" or "start + 53" means or where to look. Any guidance would be appreciated.
2011-05-11 10:43:23.071 FlowerInfoNavigator[22537:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFDictionary objectForKey:]: method sent to an uninitialized mutable dictionary object'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f16313 objc_exception_throw + 44
2 CoreFoundation 0x00dbf542 -[__NSPlaceholderDictionary objectForKey:] + 194
3 FlowerInfoNavigator 0x0000289a -[RootViewController tableView:didSelectRowAtIndexPath:] + 330
4 UIKit 0x0008bb68 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
5 UIKit 0x00081b05 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
6 Foundation 0x0079b79e __NSFireDelayedPerform + 441
7 CoreFoundation 0x00da38c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
8 CoreFoundation 0x00da4e74 __CFRunLoopDoTimer + 1220
9 CoreFoundation 0x00d012c9 __CFRunLoopRun + 1817
10 CoreFoundation 0x00d00840 CFRunLoopRunSpecific + 208
11 CoreFoundation 0x00d00761 CFRunLoopRunInMode + 97
12 GraphicsServices 0x00ffa1c4 GSEventRunModal + 217
13 GraphicsServices 0x00ffa289 GSEventRun + 115
14 UIKit 0x00022c93 UIApplicationMain + 1160
15 FlowerInfoNavigator 0x00001b99 main + 121
16 FlowerInfoNavigator 0x00001b15 start + 53
)
terminate called after throwing an instance of 'NSException'
(gdb)
On the right are the methods that were called that are on the stack. I generally just look for anything that is from one of my methods (though this won't always work) and then it'll give you the method call that the problem originated from. in the trace at call number 3 on "FlowerInfoNavigator" the method tableView:didSelectRowAtIndexPath: was called and somewhere in there is what caused the crash. You should be able to use the debugger and breakpoints to narrow it down from there hopefully. Good luck.
Edit: as I relooked at your error message: at the top of it it gives you the error. You tried to retrieve an object from a NSDictionary that wasn't initialized yet, and from above, it occurred in your didSelectRowAtIndexPath method
The console wouldn't be the only place you look. Take a look at your Debugger too. Over there there is usually one line that is bolded. If you tap that it'll show you exactly where the crash happened.
Looks like you didn't init your NSDictionary
The Crash is due to nsdictionary is not initialized yet and how to search for during a crash ,first look at console so you will get idea about what caused the crash or exception and to get where the application crashed you can check out debugger .In the debugger the the particlar line will be in bold where the application crashed.
Apart from you can also use NSZombieEnabled (BOOL) to get what is causing the application crash .More about NSZombieEnabled can be found here http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iphone_development/130-Debugging_Applications/debugging_applications.html
Note : here do make sure to make NSZombieEnabled set to NO at time of processing the application to submission to apple store.
Hope this helps.

iPhone Crash stack trace VS Crash report

Just spent some time... on a crash, without understanding it. That's a classic:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000010
Which leads me to a memory issue, addressing the invalid adress 0x10
What bothers me is that I have crash report and stack trace, which differ:
The crash report, sent by user (symbolicated successfully, that happens) :
Thread 0 Crashed:
0 libobjc.A.dylib 0x000027d8 objc_msgSend + 16
1 UIKit 0x0005e9d2 -[UIViewAnimationState animationDidStop:finished:] + 54
2 QuartzCore 0x0002d8c2 run_animation_callbacks(double, void*) + 286
3 QuartzCore 0x0002d764 CA::timer_callback(__CFRunLoopTimer*, void*) + 116
4 CoreFoundation 0x000567f4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
5 CoreFoundation 0x000562a6 __CFRunLoopDoTimer + 854
6 CoreFoundation 0x0002779e __CFRunLoopRun + 1082
7 CoreFoundation 0x00027270 CFRunLoopRunSpecific + 224
8 CoreFoundation 0x00027178 CFRunLoopRunInMode + 52
9 GraphicsServices 0x000045ec GSEventRunModal + 108
10 GraphicsServices 0x00004698 GSEventRun + 56
11 UIKit 0x0000411c -[UIApplication _run] + 396
12 UIKit 0x00002128 UIApplicationMain + 664
13 MyApp 0x00003158 main (main.m:13)
14 MyApp 0x00003120 0x1000 + 8480
The crash stack trace (catched live by an Exception Handler)
0 MyApp 0x000d79c3 0x0 + 883139
1 MyApp 0x000d790b 0x0 + 882955
2 libSystem.B.dylib 0x302765d3 _sigtramp + 42
3 UIKit 0x31eab9d9 -[UIViewAnimationState animationDidStop:finished:] + 60
4 QuartzCore 0x33a178c9 _ZL23run_animation_callbacksdPv + 292
5 QuartzCore 0x33a1776b _ZN2CAL14timer_callbackEP16__CFRunLoopTimerPv + 122
6 CoreFoundation 0x3084e7fb __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
7 CoreFoundation 0x3084e2ad __CFRunLoopDoTimer + 860
8 CoreFoundation 0x3081f7a5 __CFRunLoopRun + 1088
9 CoreFoundation 0x3081f277 CFRunLoopRunSpecific + 230
10 CoreFoundation 0x3081f17f CFRunLoopRunInMode + 58
11 GraphicsServices 0x31e445f3 GSEventRunModal + 114
12 GraphicsServices 0x31e4469f GSEventRun + 62
13 UIKit 0x31e51123 -[UIApplication _run] + 402
14 UIKit 0x31e4f12f UIApplicationMain + 670
15 MyApp 0x0000315f 0x0 + 12639
16 MyApp 0x00003128 0x0 + 12584
Both differ, and the stack trace points to the crash in my code, but at addresses I can neither symbolicate nor identify. I think the crash report indicates that a message was sent to a released instance... Probably related to the use of :
+ (void)setAnimationDelegate:(id)delegate
+ (void)setAnimationDidStopSelector:(SEL)selector
So here (finally!) are my questions:
What explains the differences between logs? (libobjc.A vs libSystem.B ??)
Does the SIGBUS comes from my code or from UIKit?
How can I decipher the stack trace upper addresses (0x000d79??, which atos doesn't resolve)
Is that what I think, an issue related to an animation failing to end? similar to this > How to unset delegate on UIView setAnimationDelegate: call?
AFAIK, setAnimationDelegate is supposed to retain delegate... Someone to confirm?
EDIT: I can't use NSZombiesEnabled, this is a crash report from a published app, a crash that I didn't manage to reproduce on development environment. I just have these logs to diagnose.
Whenever I see objc_msgSend at the top, my trust of the remaining stack is low, as the error that gives this tends to do bad things to the stack.
GuardMalloc is good for this since the attempt to do anything with deallocated space will crash the app immediately in the debugger. The stack will be intact. (This makes the app very slow, but it is a very powerful tool.)
The two stacks are the same up to the UIViewAnimationState method call. The version that came from your exception handler is showing C++ mangled names instead of the regular names shown in the crash log.
(As I understand it) _sigtramp is the system's method of calling your signal handler and is short for Signal Trampoline. The stack entries beyond that are probably your signal-handler code.
Answering my own question, weeks laters, since I had no relevant answers, most are guesses, I wished I had more precise answers, but I guess my question was unclear :
Difference is coming from the origin of the log, a sighandler vs CrashReporter service, which are happening at different times, then the stack traces are slightly different.
SIGBUS comes from UIKit, but chances are big that's on a callback initiated from my code that ends on a released object. These kind of stack traces are a pain to debug when you can't reproduce the issue, since it basically tells you "I'm crashing somewhere because of an animation", which one, where... I still didn't figured precisely. Could be anywhere, and also could be an Apple iOS bug.
The first addresses in the stack are just a dead-end where any SIGBUS stack-trace ends when a released object is called. They differs across compilations (versions), but are the same on any device, That's why they can't be symbolicated. (I would love to have a technical explanation of this, instead of my guess)
& 5. I guess I solved this bug byt being more "agressive" on canceling animations in certain cases like on deallocation of some Views...
Hope that helps someone.
You should try NSZombie, to get information about what object you've released. This is a very useful tool when you get EXC_BAD_ACCESS.
To activate NSZombie do the following:
Get info of the executable.
Go to the arguments tab.
In the "Variables to be set in the environment:" section add:
Name: NSZombieEnabled
Value: YES
Then run your app as usual and when it crashes it should tell you which deallocated object received the message.
1. I'm not 100% sure but I think the discrepancy is due to how the application is being run. In the second log it looks like you're running the application via XCode in debug mode, a sigtramp signal has been sent to indicate a EXC_BAD_ACCESS error.
2. Your code - the error may come from the UIKit library but it's a result of a problem with your usage.
3. This is where NSZombieEnabled will make your life a lot easier! If you run your application with the NSZombieEnabled flag set XCode will keep 'zombie' objects in place of deallocated objects. When a zombie object is sent a message the process will trap the error and let you know exactly what object was sent the message.
If you're using XCode 4 enable NSZombieEnabled using the following instructions...
How do I set up NSZombieEnabled in Xcode 4?
For older versions follow these instructions...
http://www.cocoadev.com/index.pl?NSZombieEnabled
4. It does indeed appear that your animation delegate has been deallocated prior to the animation completing.

iPhone App Crashing during navigation

I have a tough problem (tough for me since I'm a newb.). I have a table view app that I'm working on. It starts with a table and you navigate down to a view controller. In that view controller I'm using some sample code hooked into a button that will add a contact to the iPhone address book.
My problem is when the user navigates back to the table of data, the app crashes. Is there any advice someone can provide? Or, maybe someone I could send me code for review?
Update*
Here's the information from the console.
[Session started at 2010-07-20 22:51:46 -0500.]
2010-07-20 22:51:49.621 Infinite Possibilities[5882:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithString:]: nil argument'
*** Call stack at first throw:
(
0 CoreFoundation 0x025ff919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0274d5de objc_exception_throw + 47
2 CoreFoundation 0x025b8078 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x025b7fea +[NSException raise:format:] + 58
4 Foundation 0x0006869c -[NSPlaceholderString initWithString:] + 105
5 Infinite Possibilities 0x00003b90 -[RootViewController tableView:didSelectRowAtIndexPath:] + 3405
6 UIKit 0x0034c718 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
7 UIKit 0x00342ffe -[UITableView _userSelectRowAtIndexPath:] + 219
8 Foundation 0x00059cea __NSFireDelayedPerform + 441
9 CoreFoundation 0x025e0d43 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
10 CoreFoundation 0x025e2384 __CFRunLoopDoTimer + 1364
11 CoreFoundation 0x0253ed09 __CFRunLoopRun + 1817
12 CoreFoundation 0x0253e280 CFRunLoopRunSpecific + 208
13 CoreFoundation 0x0253e1a1 CFRunLoopRunInMode + 97
14 GraphicsServices 0x02e642c8 GSEventRunModal + 217
15 GraphicsServices 0x02e6438d GSEventRun + 115
16 UIKit 0x002e8b58 UIApplicationMain + 1160
17 Infinite Possibilities 0x00002834 main + 102
18 Infinite Possibilities 0x000027c5 start + 53
)
terminate called after throwing an instance of 'NSException'
Usually a crash means you have some sort of memory problem or calling a undefined function(sending a message that is not answered by the receiver).
Are trying to read from a pointer to an object that was released already?
Are you trying to send a message to an object that is not answering to it?
The good news is that you have a lot of good tools to find out exactly what it is:
First of all, open the console (Shift + Command R) and see if there is a message or stack trace when your app crashes. If there is no message, run the debugger (Shift + Command Y) and see where it stops on the crash.
Finally, if you see the status bar of XCode, it will tell you a bit of information about the crash (the message that was send about the crash, could be a EXEC_BAD_ADDRESS or some other thing.
Sadly, without your code or any of this information this is all I can do to help you. I would suggest not only copy and pasting but really understanding what that code is supposed to be doing and also learning how to debug your code.
For good resources I would recommend the Itunes U Standford Iphone development class and/or reading a good book about it(I read the Head First Iphone book and I love the series but didn't really like this one).

Crash invalidates url for NSPersistentStoreCoordinator

I have a Core Data app that has a bug that causes the app to crash and I have not tracked down its cause yet. One of the results of the crash is that the next time the app is started up it can not open the persistent store used by the application previously. The following error is returned from the addPersistentStoreWithType: method:
NSUnderlyingException = Error validating url for store;
And, of course, it cannot retrieve any of the objects previously stored by the app. Does anyone know what can cause an app to no longer be able to find its persistent store?
The crash that causes the app to shut down prior to all this happening produces the following crash log:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Thread 0 Crashed:
0 libSystem.B.dylib 0x0007e98c __kill + 8
1 libSystem.B.dylib 0x0007e97c kill + 4
2 libSystem.B.dylib 0x0007e96e raise + 10
3 libSystem.B.dylib 0x0009361a abort + 34
4 libstdc++.6.dylib 0x000453b0 __gnu_cxx::__verbose_terminate_handler() + 376
5 libobjc.A.dylib 0x00005858 _objc_terminate + 104
6 libstdc++.6.dylib 0x00043776 __cxxabiv1::__terminate(void (*)()) + 46
7 libstdc++.6.dylib 0x000437ca std::terminate() + 10
8 libstdc++.6.dylib 0x00043896 __cxa_throw + 74
9 libobjc.A.dylib 0x00004714 objc_exception_throw + 64
10 Foundation 0x000013c2 __NSThreadPerformPerform + 570
11 CoreFoundation 0x00056a96 CFRunLoopRunSpecific + 1834
12 CoreFoundation 0x00056356 CFRunLoopRunInMode + 42
13 GraphicsServices 0x00003b2c GSEventRunModal + 108
14 GraphicsServices 0x00003bd8 GSEventRun + 56
15 UIKit 0x00002768 -[UIApplication _run] + 384
16 UIKit 0x0000146c UIApplicationMain + 688
17 Meetchu 0x00002568 main (main.m:14)
18 Meetchu 0x0000251c start + 32
I cannot figure out what is happening from this information. Can anyone help with either of these errors?
Many thanks in advance.
If you're storing the actual URL to a file in the app's directory instead of regenerating it each time relative to the app directory, then the invalid URL is the result of the simulator/device changing the name of the app directory to a random UUID. It does that sometimes in response to crashes.
The obvious first step is the log the URL and see if the store is actually at that location.
Drew,
Without seeing some code, I can tell you that one source of agony to me when I first started with Core Data was versioning your models. If you have changed your managed object model in any way, this will cause your app to crash without some versioning (i.e., lightweight) code in place.
This may not be the source of your problem, but one thing you can try is to either remove your app from your iPhone Simulator or use "Reset Contents and Settings" from the iPhone simulator menu. If this fixes the problem, then you're looking at a migrations issue.
Cheers.