How do you add diagnostic information to iOS crash reports? - ios

I'd like to be able to include diagnostic information in an iOS crash report. Part of the motivation is to include more information about the cause of the error and earlier stack traces.
In my scenario I have control over an NSException object that is thrown. That is, the crashes aren't due to segfaults, for instance. However, the default crash report (e.g. from TestFlight) hides NSException fields like name, reason, and userInfo:
NSException *exception = [NSException exceptionWithName:name
reason:reason
userInfo:userInfo];
#throw exception;
produces:
Incident Identifier: 00000000-0000-0000-0000-000000000000
Hardware Model: iPhone13,3
Process: Example [12345]
...
Date/Time: 2022-08-11 12:21:45.7780 +0000
Launch Time: 2022-08-11 12:20:45.7780 +0000
OS Version: iPhone OS 15.6 (19G71)
...
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 5
Last Exception Backtrace:
0 CoreFoundation 0x1951a5288 __exceptionPreprocess + 220 (NSException.m:200)
1 libobjc.A.dylib 0x1aded4744 objc_exception_throw + 60 (objc-exception.mm:565)
2 Example 0x102bc379c -[Example throwException:] + 24 (Example.m:422)
3 Example 0x102bd7964 -[Example _crash] + 984 (Example.m:222)
...
8 libdispatch.dylib 0x194e14c80 _dispatch_lane_invoke + 392 (queue.c:3944)
9 libdispatch.dylib 0x194e1f500 _dispatch_workloop_worker_thread + 648 (queue.c:6732)
10 libsystem_pthread.dylib 0x206b050bc _pthread_wqthread + 288 (pthread.c:2599)
11 libsystem_pthread.dylib 0x206b04e5c start_wqthread + 8
Is there any way to add more diagnostics information to these crash reports?

Related

Setting CALayer transform property causes a crash

I am building an interactive rotating disc control. When the user drags the view, I apply the rotation transform for the view. Like this:
circleView.layer.transform = CATransform3DMakeRotation(angle, 0, 0, 1)
For some reason, this line of code causes the app to crash. The crash is not happening on the first hit of this line, but after a
few seconds of consecutive rotation. If I comment this line out, the crash is not occurring.
To make things worse, when the app crashes xcode doesn't show any error or stacktrace but says "connection to device is lost".
This happening only on a device. On the simulator all goes fine.
In the crash logs of the device, at the time of the crash I see no crashes of my apps but there is a crash of processes DTServiceHub
Incident Identifier: 02336F7A-CAB3-4B13-9509-65EA61813529
CrashReporter Key: e16756d8ab2514bab0584705f4151434dbed594f
Hardware Model: iPad3,4
Process: DTServiceHub [768]
Path: /Developer/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/DTServiceHub
Identifier: DTServiceHub
Version: ???
Code Type: ARM (Native)
Role: Unspecified
Parent Process: launchd [1]
Coalition: <none> [352]
Date/Time: 2018-10-02 18:26:03.0352 +0300
Launch Time: 2018-10-02 18:25:45.0000 +0300
OS Version: iPhone OS 10.3.3 (14G60)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0bd5f30c
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
hread 6 name: Dispatch queue: NStatManager queue
Thread 6 Crashed:
0 libobjc.A.dylib 0x1d404dc6 objc_msgSend + 6
1 CoreFoundation 0x1e086210 -[__NSDictionaryM objectForKey:] + 128
2 IDEDebugGaugeDataProviders 0x00439278 0x430000 + 37496
3 IDEDebugGaugeDataProviders 0x004382a8 0x430000 + 33448
4 NetworkStatistics 0x240ab374 -[NWStatisticsDelegateBlockWrapper sourceDidReceiveCounts:] + 160
5 NetworkStatistics 0x240a548c __59-[NWStatisticsManager dispatchDidReceiveCounts:fromUpdate:]_block_invoke + 110
6 libdispatch.dylib 0x1d83d796 _dispatch_call_block_and_release + 10
7 libdispatch.dylib 0x1d84a59c _dispatch_queue_serial_drain + 854
8 libdispatch.dylib 0x1d840b70 _dispatch_queue_invoke + 886
9 libdispatch.dylib 0x1d84c1b4 _dispatch_root_queue_drain + 326
10 libdispatch.dylib 0x1d84c00e _dispatch_worker_thread3 + 106
11 libsystem_pthread.dylib 0x1d9f287c _pthread_wqthread + 1040
12 libsystem_pthread.dylib 0x1d9f245c start_wqthread + 8
Any ideas?

Is it possible to catch 3rd party iOS library exception?

My Objective-C application is using a 3rd party VoIP SDK. I found the application crashes if left running overnight. The crash only happens if I enable the SDK, so I strongly suspect it causes the crash.
The library is a static library (.a extension). I tried catching the exception using try-catch block, and NSSetUncaughtExceptionHandler, but it didn't work. I suspect those methods only work with Objective-C exceptions, and the SDK is written in native C?
Is it possible to catch a 3rd party native C exception? I'm fine with any kind of hacks, since this will not be going into production code. Just trying to get to the bottom of the issue.
EDIT:
Here's the crash log:
Hardware Model: iPad5,1
Version: 0.14 (6.0)
Beta: YES
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Date/Time: 2016-11-22 08:24:59.7336 -0500
Launch Time: 2016-11-21 13:45:09.9956 -0500
OS Version: iPhone OS 10.1.1 (14B100)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Application Specific Information:
abort() called
Filtered syslog:
None found
Last Exception Backtrace:
(0x18953e1c0 0x187f7855c 0x18953e108 0x18f89359c 0x18f6f4444 0x18f4c653c
0x18f391d48 0x18f391c78 0x18f44bb10 0x18f44aec0 0x18f44a90c 0x18f44a4c0
0x18f44a424 0x18f38f220 0x18c84f188 0x18c843e64 0x18c843d24 0x18c7c07ec
0x18c7e7c58 0x18c7e8678 0x1894eb7dc 0x1894e940c 0x1894e989c 0x189418048
0x18ae9e198 0x18f3fd2fc 0x18f3f8034 0x10002304c 0x1883fc5b8)
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x000000018850e014 0x1884ef000 + 126996
1 libsystem_pthread.dylib 0x00000001885d6450 0x1885d1000 + 21584
2 libsystem_c.dylib 0x00000001884823e0 0x18841f000 + 406496
3 libc++abi.dylib 0x0000000187f4d2d4 0x187f4c000 + 4820
4 libc++abi.dylib 0x0000000187f6acc0 0x187f4c000 + 126144
5 libobjc.A.dylib 0x0000000187f78844 0x187f70000 + 34884
6 libc++abi.dylib 0x0000000187f6766c 0x187f4c000 + 112236
7 libc++abi.dylib 0x0000000187f67234 0x187f4c000 + 111156
8 libobjc.A.dylib 0x0000000187f7871c 0x187f70000 + 34588
9 CoreFoundation 0x00000001894180bc 0x18940f000 + 37052
10 GraphicsServices 0x000000018ae9e198 0x18ae92000 + 49560
11 UIKit 0x000000018f3fd2fc 0x18f382000 + 504572
12 UIKit 0x000000018f3f8034 0x18f382000 + 483380
13 Remote 0x000000010002304c 0x100008000 + 110668
14 libdyld.dylib 0x00000001883fc5b8 0x1883f8000 + 17848
That isn't a catchable exception, that is a hard crash. And, specifically, it is a purposeful crash; something on the main thread decided things had gone badly enough that it called abort().
So, no, nothing you can do to catch it and it isn't even clear that the crash is triggered by the 3rd party library, given that crash log.

My app is rejected with Exception EXC_BREAKPOINT (SIGTRAP)

I tested my app on iPhone and iPad devices and it works fine, also I tested it on iOS 10.1.1 and on IPV6 network and it also works fine but after uploading my app to the app store, it is rejected because it crashes when login if the device is offline or on Wifi. They gave me a crash report and after I symplocited it, I get thhis Info :
Date/Time: 2016-11-01 10:07:03.2150 -0700
Launch Time: 2016-11-01 10:05:21.7124 -0700
OS Version: iPhone OS 10.1 (14B72)
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001000f18c0
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [0]
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 MyApp -[FIRMessagingSecureSocket closeStream:] (in MyApp) + 56
1 MyApp -[FIRMessagingRmq2PersistentStore openDatabase:] (in MyApp) + 228
2 MyApp -[FIRMessagingReceiver didSendDataMessageWithID:] (in MyApp) + 128
3 Foundation 0x00000001835e08f8
4 CoreFoundation 0x0000000182aa48f4
5 CoreFoundation 0x0000000182aa4608
6 CoreFoundation 0x0000000182aa3ec4
7 CoreFoundation 0x0000000182aa1ac0
8 CoreFoundation 0x00000001829d0048
9 GraphicsServices 0x0000000184456198
10 UIKit 0x00000001889b42fc
11 UIKit 0x00000001889af034
12 MyApp -[FIRMessagingClient tryToConnect] (in MyApp) + 212
13 libdyld.dylib 0x00000001819b45b8
update :
I published new version put also get this crash log
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001000a1658
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [0]
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 MyApp [FIRAMeasurement setUserAttributeOnWorkerQueue:] (in MyApp) + 580
1 MyApp [FIRAMeasurement uploadData] (MyApp) + 180 0x100054000 + 303808
2 MyApp [FIRAMeasurement reportOSUpdateOnWorkerQueue] (in PetCasa Vet) + 124
3 Foundation 0x0000000187acc8f8 0x1879c1000 + 1095928
4 CoreFoundation 0x0000000186f908f4 0x186eb3000 + 907508
5 CoreFoundation 0x0000000186f90608 0x186eb3000 + 906760
6 CoreFoundation 0x0000000186f8fec4 0x186eb3000 + 904900
7 CoreFoundation 0x0000000186f8dac0 0x186eb3000 + 895680
8 CoreFoundation 0x0000000186ebc048 0x186eb3000 + 36936
9 GraphicsServices 0x0000000188942198 0x188936000 + 49560
10 UIKit 0x000000018cea02fc 0x18ce25000 + 504572
11 UIKit 0x000000018ce9b034 0x18ce25000 + 483380
12 MyApp 0x00000001000907d8 (in MyApp) + 448
13 libdyld.dylib 0x0000000185ea05b8 0x185e9c000 + 17848
and this log crash :
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001000e5658
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [0]
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 MyApp 0x00000001000e5658 (in MyApp) + 1060
1 MyApp [FIRMessagingConnection loginRequestWithToken:authID:] (in MyApp) + 300
2 MyApp [FIRMessagingConnection initWithAuthID:token:host:port:runLoop:rmq2Manager:gcmManager:] (in MyApp) + 32
3 Foundation 0x0000000187acc8f8 0x1879c1000 + 1095928
4 CoreFoundation 0x0000000186f908f4 0x186eb3000 + 907508
5 CoreFoundation 0x0000000186f90608 0x186eb3000 + 906760
6 CoreFoundation 0x0000000186f8fec4 0x186eb3000 + 904900
7 CoreFoundation 0x0000000186f8dac0 0x186eb3000 + 895680
8 CoreFoundation 0x0000000186ebc048 0x186eb3000 + 36936
9 GraphicsServices 0x0000000188942198 0x188936000 + 49560
10 UIKit 0x000000018cea02fc 0x18ce25000 + 504572
11 UIKit 0x000000018ce9b034 0x18ce25000 + 483380
12 MyApp [FIRInstanceIDRegistrationClient parseToken:authToken:withRequestID:handler:] (in MyApp) + 564
13 libdyld.dylib 0x0000000185ea05b8 0x185e9c000 + 17848
From apple documentation
Trace Trap [EXC_BREAKPOINT // SIGTRAP]
......
......
Swift code will terminate with this exception type if an unexpected
condition is encountered at runtime such as:
1- a non-optional type with a nil
2- value a failed forced type conversion
In my app I use location and I send it to backend, and it works fine, but when opening app at first time, system show alert to say that my app want to use your location allow or not allow, if user didn't allow so location methods will not work and location will be nil and unfortunately I didn't check if location is nil so when unwrap it app crashed, it's my mistake.
Please send message to the Apple review team about same and ask to them
"We tested application on iPhone 6, 6s, 7 and 7+ with iOS 10.x and application works perfect in IPV6 network, We follow following process for IPV6 network: http://www.brianjcoleman.com/tutorial-how-to-test-your-app-for-ipv6-compatibility/" and request to them your event will be held on the coming week so, please release application to store asap and let me know the flow of the application, where you find issue or crashes.
It works, I had done same thing with 4 application and they approved.

ios app runs perfectly in debug mode but crashes in release

My app crashes in certain moments in release build. I don't know if it is important but I use mainly c++ with cocos2d-x framework. I tried setting optimization level to none but it won't work too. I get this output in console :
libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: map::at: key not found
This is part of the crash log:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3870d1f0 0x386fa000 + 78320
1 libsystem_pthread.dylib 0x38777792 0x38774000 + 14226
2 libsystem_c.dylib 0x386bdfd8 0x38675000 + 298968
3 libc++abi.dylib 0x379eccd2 0x379ec000 + 3282
4 libc++abi.dylib 0x37a056aa 0x379ec000 + 104106
5 libobjc.A.dylib 0x3814af86 0x38147000 + 16262
6 libc++abi.dylib 0x37a031c4 0x379ec000 + 94660
7 libc++abi.dylib 0x37a02d28 0x379ec000 + 93480
8 libobjc.A.dylib 0x3814ae12 0x38147000 + 15890
9 CoreFoundation 0x2d3d2f80 0x2d3cb000 + 32640
10 CoreFoundation 0x2d3d2cee 0x2d3cb000 + 31982
11 GraphicsServices 0x3230565e 0x322fc000 + 38494
12 UIKit 0x2fd1e168 0x2fcb0000 + 450920
13 BumpRace iOS 0x00044b1e 0x4000 + 264990
14 libdyld.dylib 0x38657ab4 0x38656000 + 6836
Any help would be apprieciated.
You must use iOS instruments tool. To debug you memory leaks. As possible to conclude from youre ERROR message.
Small useful link.

List of iOS exception codes

I'm trying to debug a crash my app is seeing (very rare) in SBJson and I don't know how to decipher the exception code:
Date/Time: 2012-12-16 12:21:31.311 -0500
OS Version: iOS 6.0.1 (10A523)
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000000000defe
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 CoreFoundation 0x3a0a92be CFRelease + 18
1 libcache.dylib 0x369217d2 _entry_remove + 154
2 libcache.dylib 0x369221d8 _cache_enforce_limits + 168
3 libcache.dylib 0x3692115e _cache_update_limits + 170
4 libcache.dylib 0x3692156c cache_set_and_retain + 1028
5 CoreFoundation 0x3a0fc480 -[NSCache setObject:forKey:cost:] + 52
6 CoreFoundation 0x3a0fc442 -[NSCache setObject:forKey:] + 38
7 MyApp 0x000c4226 -[SBJsonStreamWriter writeString:] (SBJsonStreamWriter.m:315)
8 MyApp 0x000c3460 -[SBJsonStreamWriter writeObject:] (SBJsonStreamWriter.m:104)
9 MyApp 0x000c613c -[SBJsonWriter dataWithObject:] (SBJsonWriter.m:93)
10 MyApp 0x000c5efc -[SBJsonWriter stringWithObject:] (SBJsonWriter.m:61)
11 MyApp 0x000c14d0 -[NSObject(NSObject_SBJsonWriting) JSONRepresentation] (NSObject+SBJson.m:38)
Apple provides some documentation here:
http://developer.apple.com/library/ios/#technotes/tn2151/_index.html
but the 0x0000000000000001, 0x000000000000defe exception code isn't listed. Anyone know where I can get a more complete list?
Are you sure the json you are passing is correct? Try validating it at some third party. I use this: http://paulisageek.com/json_validator/

Resources