Which library is causing this crash? - ios

I've got a symbolicated stack trace that's giving me a headache! Annoyingly, I can't reproduce this on any of our test devices so I only have the crash reports to work from.
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (NSURLResponseInternal)'
Last Exception Backtrace: CoreFoundation
0x2ac7af8f __exceptionPreprocess + 126 libobjc.A.dylib
0x3932bc8b objc_exception_throw + 38 CoreFoundation
0x2ac7aed5 -[NSException initWithCoder:] + 0 Foundation
0x2ba218d1 0x2b8ef000 + 632 Foundation
0x2ba23463 ___writeJSONObject_block_invoke + 186 CoreFoundation
0x2ab96f5d __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 92 CoreFoundation
0x2ab96e7f -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 174 Foundation
0x2ba230e3 _writeJSONObject + 414 Foundation
0x2ba2180f _writeJSONValue + 438 Foundation
0x2ba21625 -[_NSJSONWriter dataWithRootObject:options:error:] + 128 Foundation
0x2ba224bf +[NSJSONSerialization dataWithJSONObject:options:error:] + 338 whats-new
0x00315fa3 0xc9000 (WNLoadingView.m:28) whats-new
0x00318683 0xc9000 (WNLoadingView.m:28) whats-new
0x003199fb 0xc9000 (WNLoadingView.m:28) libdispatch.dylib
0x398bc2cf _dispatch_client_callout + 22 libdispatch.dylib
0x398c3a3d _dispatch_barrier_sync_f_invoke + 48 whats-new
0x00319911 0xc9000 (WNLoadingView.m:28) whats-new
0x003185bb 0xc9000 (WNLoadingView.m:28) whats-new
0x0031fac3 0xc9000 (WNLoadingView.m:28) whats-new
0x0031f97f 0xc9000 (WNLoadingView.m:28) whats-new
0x0031dce3 0xc9000 (WNLoadingView.m:28) libdispatch.dylib
0x398bc2e3 _dispatch_call_block_and_release + 10 libdispatch.dylib
0x398c3dff _dispatch_after_timer_callback + 66 libdispatch.dylib
0x398ce173 _dispatch_source_latch_and_call + 1606 libdispatch.dylib
0x398bde15 _dispatch_source_invoke + 212 libdispatch.dylib
0x398c4397 _dispatch_queue_drain + 554 libdispatch.dylib
0x398beaad _dispatch_queue_invoke + 84 libdispatch.dylib
0x398c5f9f _dispatch_root_queue_drain + 394 libdispatch.dylib
0x398c73c3 _dispatch_worker_thread3 + 94 libsystem_pthread.dylib
0x39a20db5 _pthread_wqthread + 668 libsystem_pthread.dylib
0x39a20b08 start_wqthread + 8
The reason for the crash is pretty obvious (and isn't my question!) - I'm trying to write a non-jsonable object into json data. The tricky part is working out exactly where this is happening.
All the references to WNLoadingView.m are a complete red herring - that line of WNLoadingView is just #implementation WNLoadingView and the address 0xc9000 is just the starting point of our binary in memory. However, 0x00315fa3 looks like it's in our space but I don't know how to see what's actually there :)
Sigh.
My current theory is that the crash is occurring in a library that I don't have debug information for (i.e. a 3rd party .a linked from a pod).
I guess I have two questions;
How can I use this stack trace to find out which library is causing this?
or
If my theory isn't correct, does anyone know another approach to try or have another theory?

There's a couple of avenues that you might pursue:
Get yourself a fully-symbolicated crash log. I've found this post to be incredibly helpful, specifically the answer by Andreas (which is NOT the accepted answer, unfortunately). If you can get this to work, you may not need anything else.
Use the link map for your binary to determine where the address in question (0x00315fa3) resides. This can potentially be unsolvable if you didn't set up your build to produce a link map ahead of time for the version of your app that's on the app store (or even an older one), but there's a small chance that you can potentially get in the ballpark by rebuilding the app from scratch at the same commit point in your version control system you used to build the app originally (YMM GREATLY V). Regardless of whether you're already set up or need to set up your build to produce one, you'll want one going forward; read the first part of the second post for instructions on setting up your build in Xcode to produce a link map, and where to find it once it's been generated. If you use command-line tools to build your app for submission, you'll need to dig up the relevant switch(es) (you can use your Xcode build changes to determine what it does and use that in your build script/command). The link map is useful because it can tell you about files/methods from ALL of the app's source code, including third-party libraries, even when you don't have the source for them (it's a complete map of your entire app, not just your code); you can still get useful hints about the overall call flow that led directly to the crash.
While the purpose of the second post doesn't directly address your problem (and are frankly overkill for your specific question), many of the ideas about how to read the link map and the tools you can use to automate certain tasks should give you sufficient insight about how to glean the information that's of relevance. Specifically, you'll want to find the file/method invocation whose address range contains the address in question (0x00315fa3), and, if all goes well (meaning you have an accurate map), that information should point you right to the offending library, file, and method.

Related

Can't symbolicate crash logs

I experiencing a crash in my app:
Thread 0 name:
Thread 0 Crashed:
0 LogoQuizAC 0x0000000104705218 __hidden#563_ + 0 (__hidden#957_:0)
1 LogoQuizAC 0x0000000104705218 _hidden#18_ + 592 (__hidden#957_:135)
2 LogoQuizAC 0x000000010470503c __hidden#564_ + 48 (__hidden#456_:0)
3 LogoQuizAC 0x000000010470503c _hidden#18_ + 116 (__hidden#957_:135)
4 LogoQuizAC 0x00000001046fcd6c _hidden#17_ + 504 (__hidden#454_:96)
5 LogoQuizAC 0x00000001046fcea0 _hidden#20_ + 36 (__hidden#456_:0)
6 Foundation 0x0000000182770b20 __NSFireTimer + 68 (NSTimer.m:270)
7 CoreFoundation 0x0000000181355fa0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32 (CFRunLoop.c:1807)
8 CoreFoundation 0x0000000181355ba0 __CFRunLoopDoTimer + 1064 (CFRunLoop.c:2415)
9 CoreFoundation 0x0000000181354ffc __CFRunLoopDoTimers + 328 (CFRunLoop.c:2575)
10 CoreFoundation 0x000000018134eee4 __CFRunLoopRun + 1936 (CFRunLoop.c:3090)
11 CoreFoundation 0x000000018134e21c CFRunLoopRunSpecific + 600 (CFRunLoop.c:3242)
12 GraphicsServices 0x0000000198f18784 GSEventRunModal + 164 (GSEvent.c:2259)
13 UIKitCore 0x0000000183d8eee8 -[UIApplication _run] + 1072 (UIApplication.m:3253)
14 UIKitCore 0x0000000183d9475c UIApplicationMain + 168 (UIApplication.m:4707)
15 LogoQuizAC 0x000000010453a404 main + 68 (RLockedCell.swift:21)
16 libdyld.dylib 0x000000018100e6b0 start + 4
I tried almost everything but can symbolicate the crash.
I tried using symbolicatecrash followed by these posts:
(_hidden#919_:0) inside crash symbolication file
Why aren't the crashlogs from Testflight symbolicating in Xcode?
Xcode Crash Organizer does Not Symbolicate .xccrashpoint Files
How to symbolicate crash log with Xcode 8?
how Symbolicate a crash file using xcarchive
How to symbolicate crash log Xcode?
But without any success.
What am I doing wrong? How can I figure out what causing the crash?
The good news that it is crashing in your code, not in Operating Systems or Library code, so you have a good chance to debug it. Your code that is crashing is running off a timer. Sometimes these bugs are seen because in testing, you are just testing the app. But in the real world, those timers fire when you are not expecting them.
For example, someone ran your app, then put it into the background when using another app, or for example they received a phone call whilst using the app. If you attach the full contents of the .crash file, it will give more information on the cause of the crash.
Another thing you can do is place asserts into your code, such as in your timer callback functions for each object you are relying on being non-null.
You may find that your app is trying to draw onto the screen but is in the background. This is a common reason for a crash seen in the field for games that use timers. That may sound like a generalisation but it is a suggestion to try and make you think differently about the real world environment your customers face which can the reason for the failure.

What will be the issue when crash log contains _dispatch_call_block_and_release + 24

Below I have given the crash log from crashlytics, no other information available.On checking the logs, the issue occurs at different scenarios each time. Could not replicate the issue. Could anyone help me out to analyse the issue in Apple tvos application.
Crashed: com.apple.main-thread
SIGTRAP 0x0000000....
0
InsightAgentTVOS
(Missing)
1
InsightAgentTVOS
(Missing)
2
InsightAgentTVOS
(Missing)
3
InsightAgentTVOS
(Missing)
4
InsightAgentTVOS
(Missing)
5
InsightAgentTVOS
(Missing)
3
libdispatch.dylib
_dispatch_call_block_and_release + 24
4
libdispatch.dylib
_dispatch_client_callout + 16
5
libdispatch.dylib
_dispatch_main_queue_callback_4CF + 872
6
CoreFoundation
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
7
CoreFoundation
__CFRunLoopRun + 2480
8
CoreFoundation
CFRunLoopRunSpecific + 572
9
GraphicsServices
GSEventRunModal + 160
10
UIKitCore
-[UIApplication _run] + 1060
11
UIKitCore
UIApplicationMain + 164
The _dispatch_call_block_and_release is almost certainly not the issue (though it suggests that the underlying probably might be in some block that you dispatched with GCD). The SIGTRAP is suggests that the problem may be Swift runtime error, such as forced unwrapping/casting. For general overview of crash reports, refer to Analyzing a Crash Report.
FYI, the “(Missing)” might suggest that is this code was was not symbolicated or the wrong compilation options. When it’s built correctly, the crash reports show you the exact line number in one’s code. That eliminates the guesswork.
Above, I assumed that InsightAgentTVOS was your code. If not, as Rob Napier surmised, then the problem is undoubtedly in their library. Perhaps some required parameter was not supplied. (Forced unwrapping of some optional value is a common source of this sort of problem.) If you don’t find the issue, I’d suggest you open a ticket with them, providing a MCVE.

Maybe it crashed because of afnetworking

My application crashed again, this time exporting the device crash log as follows (mind articles 11 and 12):
I tried to symbolic it, but I didn't know how to get the dSYM files from afnetworking from the project.
Thread 8 name: Dispatch queue: NSOperationQueue 0x2803df960 (QOS: UNSPECIFIED)
Thread 8 Crashed:
0 libsystem_malloc.dylib 0x0000000197cccda8 nanov2_allocate_from_block$VARIANT$armv81 + 528
1 libsystem_malloc.dylib 0x0000000197cccda8 nanov2_allocate_from_block$VARIANT$armv81 + 528
2 libsystem_malloc.dylib 0x0000000197ccc040 nanov2_allocate$VARIANT$armv81 + 140
3 libsystem_malloc.dylib 0x0000000197ccbf64 nanov2_malloc$VARIANT$armv81 + 60
4 libsystem_malloc.dylib 0x0000000197cd99a0 malloc_zone_malloc + 156
5 CoreFoundation 0x000000019808e160 _CFRuntimeCreateInstance + 324
6 CoreFoundation 0x000000019802b970 __CFArrayInit + 224
7 Foundation 0x0000000198b75470 NSKVOCopyPendingNotificationStack + 152
8 Foundation 0x0000000198b720f8 NSKeyValueWillChangeWithPerThreadPendingNotifications.llvm.16432713543580414412 + 364
9 Foundation 0x0000000198ae8ad4 -[NSProgress _setValueForKeys:settingBlock:] + 272
10 Foundation 0x0000000198aeb9dc -[NSProgress setCompletedUnitCount:] + 132
11 AFNetworking 0x00000001051c965c 0x10519c000 + 185948
12 AFNetworking 0x00000001051d1a18 0x10519c000 + 219672
13 CFNetwork 0x0000000198898b94 __67-[NSURLSession delegate_dataTask:didReceiveData:completionHandler:]_block_invoke.303 + 36
14 Foundation 0x0000000198b8c8bc __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
15 Foundation 0x0000000198a94ab8 -[NSBlockOperation main] + 72
16 Foundation 0x0000000198a93f8c -[__NSOperationInternal _start:] + 740
17 Foundation 0x0000000198b8e790 __NSOQSchedule_f + 272
18 libdispatch.dylib 0x0000000197b356c8 _dispatch_call_block_and_release + 24
19 libdispatch.dylib 0x0000000197b36484 _dispatch_client_callout + 16
20 libdispatch.dylib 0x0000000197b0ce04 _dispatch_continuation_pop$VARIANT$armv81 + 404
21 libdispatch.dylib 0x0000000197b0c4e8 _dispatch_async_redirect_invoke + 592
22 libdispatch.dylib 0x0000000197b18aec _dispatch_root_queue_drain + 344
23 libdispatch.dylib 0x0000000197b1934c _dispatch_worker_thread2 + 116
24 libsystem_pthread.dylib 0x0000000197d1917c _pthread_wqthread + 472
25 libsystem_pthread.dylib 0x0000000197d1bcec start_wqthread + 4
If it's not afnetworking fault, can anyone see why? Please help me.
So, your app has crashed pretty deep in Apple's code, and specifically inside libsystem_malloc. While I cannot be certain, my guess is you're looking at an example of heap corruption.
Dynamically allocated memory is shared by your entire process, and everything in it. That means that any code could potentially overwrite and/or otherwise corrupt structures used by other, even unrelated, parts of the system. In this case, it looks like something has messed up the internal book-keeping structures used by malloc. I would guess this happens by overrunning a buffer and writing outside of an allocated piece of memory's bounds.
What I can say with high confidence is that this particular report does not give you enough information to blame AFNetworking. It just happened to be unlucky enough to be running when that corrupt memory was accessed. Even one memory corruption bug can cause a variety of different crashes. Because of that, it's not really possible to reason about the cause of any one particular crash.
The good news is this kind of thing is very common. Bad news is it can be very hard to track down. What I'd recommend trying is to make use of the memory debugging tools that Apple provides. Things like NSZombies (via instruments), guardmalloc, and malloc scribble. Your best bet is to just fix all the memory-related bugs you can find.

Interpreting iPhone Crash Log / Stack Trace

I'm using the TestFlight SDK and have received several crash reports identical to this one. However, I'm having trouble understanding it, and what the underlying cause of the crash is from the reports?
Exception
SIGSEGV
2 libsystem_c.dylib 0x32862e92 _sigtramp + 42
3 Foundation 0x33750d1c -[NSError dealloc] + 60...
Exception reason
SIGSEGV
Stacktrace
0 MyAppName 0x0013faba testflight_backtrace + 382
1 MyAppName 0x00140708 TFSignalHandler + 264
2 libsystem_c.dylib 0x32862e92 _sigtramp + 42
3 Foundation 0x33750d1c -[NSError dealloc] + 60
4 libobjc.A.dylib 0x39230488 _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 168
5 CoreFoundation 0x31de9440 _CFAutoreleasePoolPop + 16
6 Foundation 0x33751f7a -[NSAutoreleasePool drain] + 122
7 CoreData 0x35e0a4b2 -[NSManagedObjectContext save:] + 1210
8 MyAppName 0x000b7168 MR_swapMethodsFromClass + 18076
9 CoreData 0x35e0dbc0 developerSubmittedBlockToNSManagedObjectContextPerform + 88
10 libdispatch.dylib 0x335974b6 _dispatch_client_callout + 22
11 libdispatch.dylib 0x33598dca _dispatch_main_queue_callback_4CF$VARIANT$up + 226
12 CoreFoundation 0x31e79f3a __CFRunLoopRun + 1290
13 CoreFoundation 0x31decebc CFRunLoopRunSpecific + 356
14 CoreFoundation 0x31decd48 CFRunLoopRunInMode + 104
15 GraphicsServices 0x36e092ea GSEventRunModal + 74
16 UIKit 0x320db2f8 UIApplicationMain + 1120
17 MyAppName 0x00099122 main (main.m:17)
18 MyAppName 0x000990d7 start + 39
Additional details:
Users report this crash happens 1-2 seconds after the app starts
The app uses Core Data and MagicalRecord (which is where the MR_swapMethodsFromClass method comes from)
I can't reproduce this issue on any test devices when running from Xcode (iPhone 3GS, iPhone 4, or iPhone 5) running various iOS versions (iOS 5.1, 6.0, 6.1)
EDIT
Still working on solving this issue... I've been able to recreate it (but not with a debugger attached).
Here's the strangest part-- if a user has an older version of the app and installs an update (distributed via Test Flight), they get this error.
However, if they first delete the old app and install the update, the error doesn't occur.
Let's walk through it:
0 MyAppName 0x0013faba testflight_backtrace + 382
1 MyAppName 0x00140708 TFSignalHandler + 264
That's TestFlight. This is after the crash has happened, so it's certainly not the cause.
2 libsystem_c.dylib 0x32862e92 _sigtramp + 42
This is the point at which we caught the crash. "sigtramp" is the signal "trampoline." That's a fancy way of saying "I caught a signal (crash) and now I'm going to bounce to somewhere else in the code."
3 Foundation 0x33750d1c -[NSError dealloc] + 60
Ah. This is important. We crashed while deallocating an NSError. That means the NSError was over-released or under-retained.
4 libobjc.A.dylib 0x39230488 _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 168
5 CoreFoundation 0x31de9440 _CFAutoreleasePoolPop + 16
6 Foundation 0x33751f7a -[NSAutoreleasePool drain] + 122
Sad… it manifested while draining the autorelease pool. That means the actual bug could be a long way from here. But at least we know the type of the object. NSZombies could be of use to try to find the specific object.
7 CoreData 0x35e0a4b2 -[NSManagedObjectContext save:] + 1210
And the autorelease pool was draining during a MOC save. That suggests it's probably related to your Core Data code. It's at least where you'd look first.
The things to remember are:
The bug is almost certainly in your code.
If it's not in your code, it's probably in Magical Record
Do not assume it is in Core Data. That is the least likely place for the bug given this stack.
Here's the strangest part-- if a user has an older version of the app and installs an update (distributed via Test Flight), they get this error.
However, if they first delete the old app and install the update, the error doesn't occur.
Probably in your upgrade code then. Most likely in the Core Data migration stuff. Audit every use of NSError in that area of code. Eliminate all compiler and analyzer warnings. And try NSZombies if its reproducible.
You should try to add a model version to your data model. It worked for me, i had a similar Magical-Record-related issue.

SIGSEGV symbolication points only to core classes

I am using Bugsense in my app to get crash reports.
I have a repeating bug with SIGSEGV and no other details about it.
I tried to symbolicate the report but I get this:
0 libobjc.A.dylib 0x33417f78 0x33414000 + 16248
1 CoreFoundation 0x36f651fb 0x36f4d000 + 98811
2 Foundation 0x32c42747 0x32b9e000 + 673607
3 CoreFoundation 0x36fdaad3 0x36f4d000 + 580307
4 CoreFoundation 0x36fda29f 0x36f4d000 + 578207
5 CoreFoundation 0x36fd9045 0x36f4d000 + 573509
6 CoreFoundation 0x36f5c4a5 CFRunLoopRunSpecific + 300
7 CoreFoundation 0x36f5c36d CFRunLoopRunInMode + 104
8 GraphicsServices 0x35123439 GSEventRunModal + 136
9 UIKit 0x35205cd5 UIApplicationMain + 1080
10 English Club 0x00036a2b 0x34000 + 10795
It does not point to any of my classes (In the last line 'English Club' is the name of my app).
Does that mean that this is a bug in apple classes? how can I parse this report to get somthing helpful (like what are the +1234334 numbers in this case etc.
Thank you all
Shani
Does that mean that this is a bug in apple classes?
No.
how can I parse this report to get somthing helpful
Recompile with debug symbols enabled, and run the app in the debugger. Then, if everything was done right, you'll get a symbolicated stack trace.
what are the +1234334 numbers in this case
They're offsets from the beginning of the particular function address - and you're most likely not interested in them.
Your best bet here is to enable zombies and rerun in the debugger and try to reproduce the crash manually. The bug is likely somwhere in your code where you set a delegate that points to one of your objective C objects. For example, see this question which is much like yours: SIGSEGV SEGV_ACCERR Crash Reports - What to do?

Resources