Crash on ios 15: CA::Display::DisplayLink::timer_status_callback - ios

My app crashed about 200 times per month on iOS 15, and I failed to solve it.
The crash reports shows like following:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000001f12d313c
Thread 0 Crashed:
0 libsystem_platform.dylib 0x00000001f12d313c _os_unfair_lock_corruption_abort + 88
1 libsystem_platform.dylib 0x00000001f12cda20 _os_unfair_lock_lock_slow + 320
2 QuartzCore 0x000000018441c7c4 CA::Display::DisplayTimingsControl::granularity+ 100292 (unsigned int) + 40
3 QuartzCore 0x000000018456b99c CA::Display::DisplayLink::timer_status_callback+ 1472924 (_CADisplayTimer*, CADisplayTimerAction, unsigned long long, unsigned long long, void*) + 692
4 QuartzCore 0x000000018441b678 display_timer_callback+ 95864 (__CFMachPort*, void*, long, void*) + 272
5 CoreFoundation 0x00000001806bf390 __CFMachPortPerform + 176
6 CoreFoundation 0x0000000180702724 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60
7 CoreFoundation 0x0000000180705f30 __CFRunLoopDoSource1 + 596
8 CoreFoundation 0x00000001806bfe0c __CFRunLoopRun + 2380
9 CoreFoundation 0x00000001806d33b8 CFRunLoopRunSpecific + 600
10 GraphicsServices 0x000000019c06338c GSEventRunModal + 164
11 UIKitCore 0x00000001830736a8 0x182b5a000 + 5346984
12 UIKitCore 0x0000000182df27f4 UIApplicationMain + 2092
13 IBUWireless 0x0000000104700584 main + 17796 (main.m:44)
14 (null) 0x00000001083d9a24 0x0 + 4433222180
I guess it's because a CADisPlayLink has been dealloced wrongly, but I can't figure out which one.
The source code of apple's lock is https://github.com/apple/darwin-libplatform/blob/main/src/os/lock.c
Is Apple's CADisplayLayer Opensourced? How can I fix this crash?

This crash occurs due to a dangling pointer. When any variable or object is trying to access an object that's already been deallocated, this crash occurs.
check code and trace line by line.

Related

-[EAGLContext presentRenderbuffer:] crash in iOS 14

We encountered an OpenGL related crash on ios14. It has nothing to do with the application background. The vast majority of crashes occurred on IOS 14 low-end devices, and it is not clear how to solve them.
The only possible clue is that the crash may have something to do with opening the WebView.
Monitor Type: Unix Signal
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000 at 0x00000001c7517414
Crashed Thread: 0
Pthread id: 10322737
Thread 0 Crashed:
0 libsystem_kernel.dylib __pthread_kill + 8
1 libsystem_pthread.dylib pthread_kill + 272
2 libsystem_c.dylib abort + 104
3 AppleMetalGLRenderer GLDContextRec::flushContextInternal() + 852
4 GLEngine gliPresentViewES_Exec + 188
5 OpenGLES -[EAGLContext presentRenderbuffer:] + 76
6 myapp -[EJCanvasContextWebGLScreen present] (EJCanvasContextWebGLScreen.m:142)
7 QuartzCore CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 664
8 QuartzCore display_timer_callback(__CFMachPort*, void*, long, void*) + 280
9 CoreFoundation __CFMachPortPerform + 176
10 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60
11 CoreFoundation __CFRunLoopDoSource1 + 596
12 CoreFoundation __CFRunLoopRun + 2360
13 CoreFoundation CFRunLoopRunSpecific + 600
14 GraphicsServices GSEventRunModal + 164
15 UIKitCore -[UIApplication _run] + 1072
16 UIKitCore UIApplicationMain + 168
17 myapp main (main.m:36)
18 libdyld.dylib start + 4
I'm 100% sure presentRenderBuffer works fine in iOS14.
According to the error message, it seems like a thread issue.
In my case, I use a queue to detail with all of the OpenGL things.
dispatch_sync(queue, ^{
// All of the OpenGL things
[self bindCurrentRenderBuffer];
[self presentRenderBuffer];
});
You can see my OpenGL project in Github: IRPlayer

iOS - Understanding my symbolicated crash report (help needed)

My app is rejected from the iOS store because the app is terminated after user log in. I'm not able to reproduce the problem (local devices, TestFlight), it looks like it only happens when the app is running in production.
I have symbolicated the crash report that I got from the App Store review team. I understand that a abort() is called ontThread 0. But I have a hard time understanding the crash report. I'm new to crash reports so I appreciate the help!
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
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:
0 CoreFoundation 0x192e2efe0 __exceptionPreprocess + 124
1 libobjc.A.dylib 0x191890538 objc_exception_throw + 56
2 CoreFoundation 0x192e35ef4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 140
3 CoreFoundation 0x192e32f54 ___forwarding___ + 916
4 CoreFoundation 0x192d2ed4c _CF_forwarding_prep_0 + 92
5 appname 0x1000c9ce4 -[PushPlugin setApplicationIconBadgeNumber:] (PushPlugin.m:573)
6 appname 0x10015d130 -[CDVCommandQueue execute:] + 504
7 appname 0x1000e6d98 -[CDVWKWebViewEngine handleCordovaMessage:] (CDVWKWebViewEngine.m:427)
8 appname 0x1000e6c40 -[CDVWKWebViewEngine userContentController:didReceiveScriptMessage:] (CDVWKWebViewEngine.m:413)
9 appname 0x1000e7b98 -[CDVWKWeakScriptMessageHandler userContentController:didReceiveScriptMessage:] (CDVWKWebViewEngine.m:601)
10 WebKit 0x19c729590 ScriptMessageHandlerDelegate::didPostMessage(WebKit::WebPageProxy&, WebKit::FrameInfoData const&, WebCore::SerializedScriptValue&) + 196
11 WebKit 0x19c6c8c48 WebKit::WebUserContentControllerProxy::didPostMessage(IPC::Connection&, unsigned long long, WebKit::FrameInfoData const&, unsigned long long, IPC::DataReference const&) + 176
12 WebKit 0x19c6cb0c0 void IPC::handleMessage<Messages::WebUserContentControllerProxy::DidPostMessage, WebKit::WebUserContentControllerProxy, void (WebKit::WebUserContentControllerProxy::*)(IPC::Connection&, unsigned long long, WebKit::FrameInfoData const&, unsigned long long, IPC::DataReference const&)>(IPC::Connection&, IPC::Decoder&, WebKit::WebUserContentControllerProxy*, void (WebKit::WebUserContentControllerProxy::*)(IPC::Connection&, unsigned long long, WebKit::FrameInfoData const&, unsigned long long, IPC::DataReference const&)) + 156
13 WebKit 0x19c4fbda4 IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&) + 120
14 WebKit 0x19c6a4830 WebKit::WebProcessProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 32
15 WebKit 0x19c4c1c8c IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >) + 164
16 WebKit 0x19c4c4484 IPC::Connection::dispatchOneMessage() + 232
17 JavaScriptCore 0x19769fff4 WTF::RunLoop::performWork() + 172
18 JavaScriptCore 0x1976a02cc WTF::RunLoop::performWork(void*) + 36
19 CoreFoundation 0x192ddd42c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
20 CoreFoundation 0x192ddcd9c __CFRunLoopDoSources0 + 540
21 CoreFoundation 0x192dda9a8 __CFRunLoopRun + 744
22 CoreFoundation 0x192d0ada4 CFRunLoopRunSpecific + 424
23 GraphicsServices 0x194774074 GSEventRunModal + 100
24 UIKit 0x198fbe058 UIApplicationMain + 208
25 appname 0x1000b2b78 main (main.m:32)
26 libdyld.dylib 0x191d1959c start + 4
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000191e29014 __pthread_kill + 8
1 libsystem_pthread.dylib 0x0000000191ef3264 pthread_kill + 112
2 libsystem_c.dylib 0x0000000191d9d9c4 abort + 140
3 libc++abi.dylib 0x00000001918691b0 __cxa_bad_cast + 0
4 libc++abi.dylib 0x0000000191882c04 default_unexpected_handler() + 0
5 libobjc.A.dylib 0x0000000191890820 _objc_terminate() + 124
6 libc++abi.dylib 0x000000019187f5d4 std::__terminate(void (*)()) + 16
7 libc++abi.dylib 0x000000019187eef8 __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) + 0
8 libobjc.A.dylib 0x000000019189066c _objc_exception_destructor(void*) + 0
9 CoreFoundation 0x0000000192e35ef4 __methodDescriptionForSelector + 0
10 CoreFoundation 0x0000000192e32f54 ___forwarding___ + 916
11 CoreFoundation 0x0000000192d2ed4c _CF_forwarding_prep_0 + 92
12 appname 0x00000001000c9ce4 -[PushPlugin setApplicationIconBadgeNumber:] (PushPlugin.m:573)
13 appname 0x000000010015d130 -[CDVCommandQueue execute:] + 504
14 appname 0x00000001000e6d98 -[CDVWKWebViewEngine handleCordovaMessage:] (CDVWKWebViewEngine.m:427)
15 appname 0x00000001000e6c40 -[CDVWKWebViewEngine userContentController:didReceiveScriptMessage:] (CDVWKWebViewEngine.m:413)
16 appname 0x00000001000e7b98 -[CDVWKWeakScriptMessageHandler userContentController:didReceiveScriptMessage:] (CDVWKWebViewEngine.m:601)
17 WebKit 0x000000019c729590 ScriptMessageHandlerDelegate::didPostMessage(WebKit::WebPageProxy&, WebKit::FrameInfoData const&, WebCore::SerializedScriptValue&) + 196
18 WebKit 0x000000019c6c8c48 WebKit::WebUserContentControllerProxy::didPostMessage(IPC::Connection&, unsigned long long, WebKit::FrameInfoData const&, unsigned long long, IPC::DataReference const&) + 176
19 WebKit 0x000000019c6cb0c0 void IPC::handleMessage<Messages::WebUserContentControllerProxy::DidPostMessage, WebKit::WebUserContentControllerProxy, void (WebKit::WebUserContentControllerProxy::*)(IPC::Connection&, unsigned long long, WebKit::FrameInfoData const&, unsigned long long, IPC::DataReference const&)>(IPC::Connection&, IPC::Decoder&, WebKit::WebUserContentControllerProxy*, void (WebKit::WebUserContentControllerProxy::*)(IPC::Connection&, unsigned long long, WebKit::FrameInfoData const&, unsigned long long, IPC::DataReference const&)) + 156
20 WebKit 0x000000019c4fbda4 IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&, IPC::Decoder&) + 120
21 WebKit 0x000000019c6a4830 WebKit::WebProcessProxy::didReceiveMessage(IPC::Connection&, IPC::Decoder&) + 32
22 WebKit 0x000000019c4c1c8c IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >) + 164
23 WebKit 0x000000019c4c4484 IPC::Connection::dispatchOneMessage() + 232
24 JavaScriptCore 0x000000019769fff4 WTF::RunLoop::performWork() + 172
25 JavaScriptCore 0x00000001976a02cc WTF::RunLoop::performWork(void*) + 36
26 CoreFoundation 0x0000000192ddd42c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
27 CoreFoundation 0x0000000192ddcd9c __CFRunLoopDoSources0 + 540
28 CoreFoundation 0x0000000192dda9a8 __CFRunLoopRun + 744
29 CoreFoundation 0x0000000192d0ada4 CFRunLoopRunSpecific + 424
30 GraphicsServices 0x0000000194774074 GSEventRunModal + 100
31 UIKit 0x0000000198fbe058 UIApplicationMain + 208
32 appname 0x00000001000b2b78 main (main.m:32)
33 libdyld.dylib 0x0000000191d1959c start + 4
...

Crash at _CFAutoreleasePoolPop

I got a crash from Fabric,the stack is below:
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 6806634868 objc_release + 20
1 libsystem_blocks.dylib 6813456656 _Block_release + 256
2 libobjc.A.dylib 6806640420 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 564
3 CoreFoundation 6529519172 _CFAutoreleasePoolPop + 28
4 UIKit 6605817924 _wrapRunLoopWithAutoreleasePoolHandler + 76
5 CoreFoundation 6530394704 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
6 CoreFoundation 6530382300 __CFRunLoopDoObservers + 360
7 CoreFoundation 6530383292 __CFRunLoopRun + 836
8 CoreFoundation 6529519780 CFRunLoopRunSpecific + 396
9 GraphicsServices 6682260900 GSEventRunModal + 168
10 UIKit 6606283712 UIApplicationMain + 1488
11 Spec 4297532060 main (main.m:15)
12 libdyld.dylib 6813280776 start + 4
I don't know why it would be _Block_release after (anonymous namespace)::AutoreleasePoolPage::pop(void*). Is it possible that a block was added to autoreleasepool?if possible, why the block crashed at release and it not crashed at invoke?
Ok,I had resolve this bug.The reason for the crash was that I had hook the function objectAtIndex for NSMutableArray.And If user switch from background,the app would get a crash -[UIKeyboardLayoutStar release]: message sent to deallocated.
So remove the hook code will resolve this bug.

Debug/reproduce EXC_BAD_ACCESS crash in CA::release_objects

I use Crashlytics to track crashes and I am seeing some crashes with the stack trace below:
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0xf8560b1c
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x37a20b66 objc_msgSend + 5
1 CoreFoundation 0x2d5f8e8d CFRelease + 560
2 QuartzCore 0x2fad2965 CA::release_objects(X::List<void const*>*) + 16
3 QuartzCore 0x2fad7dcf -[CAAnimation dealloc] + 54
4 libobjc.A.dylib 0x37a30b0b objc_object::sidetable_release(bool) + 174
5 CoreFoundation 0x2d5f8e8d CFRelease + 560
6 QuartzCore 0x2fada419 CA::Layer::run_animation_callbacks(void*) + 240
7 libdispatch.dylib 0x37f0a0af _dispatch_client_callout + 22
8 libdispatch.dylib 0x37f0c9a9 _dispatch_main_queue_callback_4CF + 268
9 CoreFoundation 0x2d6935b1 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
10 CoreFoundation 0x2d691e7d __CFRunLoopRun + 1308
11 CoreFoundation 0x2d5fc471 CFRunLoopRunSpecific + 524
12 CoreFoundation 0x2d5fc253 CFRunLoopRunInMode + 106
13 GraphicsServices 0x323362eb GSEventRunModal + 138
14 UIKit 0x2feb1845 UIApplicationMain + 1136
It looks like CFRelease is being called on some object twice. The problem is I have no idea which animation is causing the crash. The logs aren't very helpful as the crash happens in different places. How do I go about debugging/reproducing this crash or at the very least logging something so that I know what object is being released twice.

iPhone crash log and how to understand it

This is one crash log I've downloaded from iTunesConnect website.
Incident Identifier: 20D5CB0F-58BE-41E5-B3F6-9BC8091E518C
Hardware Model: iPhone4,1
Process: iPill [2006]
Path: /var/mobile/Applications/4567191D-1013-40F3-A02A-0B3C2552FCD3/iPill.app/iPill
Identifier: iPill
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2012-07-12 20:59:23.716 +0200
OS Version: iPhone OS 5.1.1 (9B206)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x3558688f __exceptionPreprocess + 163
1 libobjc.A.dylib 0x3792d259 objc_exception_throw + 33
2 CoreFoundation 0x354cf9db -[__NSArrayM objectAtIndex:] + 271
3 iPill 0x0008225b -[ProssimeDosi tableView:cellForRowAtIndexPath:] (ProssimeDosi.m:314)
4 UIKit 0x3301aefb -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 547
5 UIKit 0x33019fd9 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1077
6 UIKit 0x33019763 -[UITableView layoutSubviews] + 207
7 UIKit 0x32fbdf37 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 183
8 CoreFoundation 0x354e51fb -[NSObject performSelector:withObject:] + 43
9 QuartzCore 0x323b5aa5 -[CALayer layoutSublayers] + 217
10 QuartzCore 0x323b56bd CA::Layer::layout_if_needed(CA::Transaction*) + 217
11 QuartzCore 0x323b9843 CA::Context::commit_transaction(CA::Transaction*) + 227
12 QuartzCore 0x323b957f CA::Transaction::commit() + 315
13 QuartzCore 0x323b14b9 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 57
14 CoreFoundation 0x3555ab1b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 19
15 CoreFoundation 0x35558d57 __CFRunLoopDoObservers + 259
16 CoreFoundation 0x355590b1 __CFRunLoopRun + 761
17 CoreFoundation 0x354dc4a5 CFRunLoopRunSpecific + 301
18 CoreFoundation 0x354dc36d CFRunLoopRunInMode + 105
19 GraphicsServices 0x37178439 GSEventRunModal + 137
20 UIKit 0x32fe8cd5 UIApplicationMain + 1081
21 iPill 0x000799b7 main (main.m:16)
22 iPill 0x0007996c 0x78000 + 6508
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x35e3c32c __pthread_kill + 8
1 libsystem_c.dylib 0x32988208 pthread_kill + 48
2 libsystem_c.dylib 0x32981298 abort + 88
3 libc++abi.dylib 0x3593ef64 abort_message + 40
4 libc++abi.dylib 0x3593c346 _ZL17default_terminatev + 18
5 libobjc.A.dylib 0x3792d350 _objc_terminate + 140
6 libc++abi.dylib 0x3593c3be _ZL19safe_handler_callerPFvvE + 70
7 libc++abi.dylib 0x3593c44a std::terminate() + 14
8 libc++abi.dylib 0x3593d81e __cxa_rethrow + 82
9 libobjc.A.dylib 0x3792d2a2 objc_exception_rethrow + 6
10 CoreFoundation 0x354dc506 CFRunLoopRunSpecific + 398
11 CoreFoundation 0x354dc366 CFRunLoopRunInMode + 98
12 GraphicsServices 0x37178432 GSEventRunModal + 130
13 UIKit 0x32fe8cce UIApplicationMain + 1074
14 iPill 0x000799b0 main (main.m:16)
15 iPill 0x00079964 0x78000 + 6500
I've pasted only thread 0 because it seems it is the one which crashed.
This is all new to me and I have no idea how to interpret this log and solve the problem.
I've tested my App on my iPhones 4 and 4s and on a 3GS of a friend of mine and we didn't see any crash.
Now I'm getting 1 star reviews from some people saying iPill is crashing a lot.
Any help will be really appreciated.
Thanks.
I'd say to start in your tables cellForRowAtIndexpath method.
I'd hazard a guess that there's an issue with your data model and it's calling data from an array that is empty.
Just from this crashlog it looks as if you're having an out-of-bounds problem triggered by line 314 of ProssimeDosi.m due to something requesting more data than is available.
See the accepted answer here for a more elaborate explanation: Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 1 beyond bounds [0 .. 0]'

Resources