App crash SEGV_ACCERR

Can anyone please help me to interpret the crash below.


It is from a live app, these crashes come in rarely but regularly. I was not able to reproduce the crash locally.


I understand it like this:

Within a `Dispatch.Queue` block that is deallocated (thread 9, line 2) there is an object that cannot be deallocated (thread 9, line 1) because it has been already deallocated.


Is my interpretation correct and if so, how can I know which background thread is causing this?


Incident Identifier: <Removed>
CrashReporter Key:   <Removed>
Hardware Model:      iPhone7,2
Process:         MyApp [1842]
Path:            <Removed>
Identifier:      com.MyApp.MyApp
Version:         1.26.1 (180)
Code Type:       ARM-64
Parent Process:  ??? [1]


Date/Time:       2018-06-10T23:49:35Z
Launch Time:     2018-06-10T23:40:38Z
OS Version:      iPhone OS 10.3.3 (14G60)
Report Version:  104


Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0x20
Crashed Thread:  9


Thread 0:
0   libsystem_kernel.dylib               0x00000001876bb224 mach_msg_trap + 8
1   CoreFoundation                       0x000000018868ce90 __CFRunLoopServiceMachPort + 188
2   CoreFoundation                       0x000000018868aae4 __CFRunLoopRun + 1056
3   CoreFoundation                       0x00000001885bada4 CFRunLoopRunSpecific + 420
4   GraphicsServices                     0x000000018a025074 GSEventRunModal + 96
5   UIKit                                0x000000018e875c9c UIApplicationMain + 204
6   MyApp                               0x000000010007c0a4 main (AppDelegate.swift:18)
7   libdyld.dylib                        0x00000001875c959c start + 0


Thread 1:
0   libsystem_kernel.dylib               0x00000001876bb224 mach_msg_trap + 8
1   CoreFoundation                       0x000000018868ce90 __CFRunLoopServiceMachPort + 188
2   CoreFoundation                       0x000000018868aae4 __CFRunLoopRun + 1056
3   CoreFoundation                       0x00000001885bada4 CFRunLoopRunSpecific + 420
4   Foundation                           0x00000001890d5db4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300
5   Foundation                           0x00000001890f6b84 -[NSRunLoop(NSRunLoop) runUntilDate:] + 92
6   UIKit                                0x000000018f1ff830 -[UIEventFetcher threadMain] + 132
7   Foundation                           0x00000001891d3318 __NSThread__start__ + 992
8   libsystem_pthread.dylib              0x00000001877a168c _pthread_body + 236
9   libsystem_pthread.dylib              0x00000001877a159c _pthread_start + 280
10  libsystem_pthread.dylib              0x000000018779ecb4 thread_start + 0


Thread 2:
0   libsystem_kernel.dylib               0x00000001876bb224 mach_msg_trap + 8
1   CoreFoundation                       0x000000018868ce90 __CFRunLoopServiceMachPort + 188
2   CoreFoundation                       0x000000018868aae4 __CFRunLoopRun + 1056
3   CoreFoundation                       0x00000001885bada4 CFRunLoopRunSpecific + 420
4   Foundation                           0x00000001890d5db4 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 300
5   Foundation                           0x000000018912a704 -[NSRunLoop(NSRunLoop) run] + 84
6   MyApp                               0x0000000100392520 +[GAI threadMain:] + 60
7   Foundation                           0x00000001891d3318 __NSThread__start__ + 992
8   libsystem_pthread.dylib              0x00000001877a168c _pthread_body + 236
9   libsystem_pthread.dylib              0x00000001877a159c _pthread_start + 280
10  libsystem_pthread.dylib              0x000000018779ecb4 thread_start + 0


Thread 3:
0   libsystem_kernel.dylib               0x00000001876bb224 mach_msg_trap + 8
1   CoreFoundation                       0x000000018868ce90 __CFRunLoopServiceMachPort + 188
2   CoreFoundation                       0x000000018868aae4 __CFRunLoopRun + 1056
3   CoreFoundation                       0x00000001885bada4 CFRunLoopRunSpecific + 420
4   CFNetwork                            0x0000000188dc7df4 +[NSURLConnection(Loader) _resourceLoadLoop:] + 400
5   Foundation                           0x00000001891d3318 __NSThread__start__ + 992
6   libsystem_pthread.dylib              0x00000001877a168c _pthread_body + 236
7   libsystem_pthread.dylib              0x00000001877a159c _pthread_start + 280
8   libsystem_pthread.dylib              0x000000018779ecb4 thread_start + 0


Thread 4:
0   libsystem_kernel.dylib               0x00000001876bb224 mach_msg_trap + 8
1   CoreFoundation                       0x000000018868ce90 __CFRunLoopServiceMachPort + 188
2   CoreFoundation                       0x000000018868aae4 __CFRunLoopRun + 1056
3   CoreFoundation                       0x00000001885bada4 CFRunLoopRunSpecific + 420
4   AVFAudio                             0x00000001a29014f4 GenericRunLoopThread::Entry(void*) + 160
5   AVFAudio                             0x00000001a2927814 CAPThread::Entry(CAPThread*) + 80
6   libsystem_pthread.dylib              0x00000001877a168c _pthread_body + 236
7   libsystem_pthread.dylib              0x00000001877a159c _pthread_start + 280
8   libsystem_pthread.dylib              0x000000018779ecb4 thread_start + 0


Thread 5:
0   libsystem_kernel.dylib               0x00000001876bb224 mach_msg_trap + 8
1   CoreFoundation                       0x000000018868ce90 __CFRunLoopServiceMachPort + 188
2   CoreFoundation                       0x000000018868aae4 __CFRunLoopRun + 1056
3   CoreFoundation                       0x00000001885bada4 CFRunLoopRunSpecific + 420
4   GeoServices                          0x00000001906d4854 _runNetworkThread + 440
5   libsystem_pthread.dylib              0x00000001877a168c _pthread_body + 236
6   libsystem_pthread.dylib              0x00000001877a159c _pthread_start + 280
7   libsystem_pthread.dylib              0x000000018779ecb4 thread_start + 0


Thread 6:
0   libsystem_kernel.dylib               0x00000001876d9a88 __workq_kernreturn + 8
1   libsystem_pthread.dylib              0x000000018779ecac start_wqthread + 0


Thread 7:
0   libsystem_kernel.dylib               0x00000001876d9a88 __workq_kernreturn + 8
1   libsystem_pthread.dylib              0x000000018779ecac start_wqthread + 0


Thread 8:
0   libsystem_kernel.dylib               0x00000001876d9a88 __workq_kernreturn + 8
1   libsystem_pthread.dylib              0x000000018779ecac start_wqthread + 0


Thread 9 Crashed:
0   libobjc.A.dylib                      0x000000018715d7f4 objc_object::release() + 8
1   libsystem_blocks.dylib               0x00000001875eba68 _Block_release + 156
2   libdispatch.dylib                    0x00000001875969a0 _dispatch_client_callout + 12
3   libdispatch.dylib                    0x00000001875a4ad4 _dispatch_queue_serial_drain + 924
4   libdispatch.dylib                    0x000000018759a2cc _dispatch_queue_invoke + 880
5   libdispatch.dylib                    0x00000001875a4fa8 _dispatch_queue_override_invoke + 340
6   libdispatch.dylib                    0x00000001875a6a50 _dispatch_root_queue_drain + 536
7   libdispatch.dylib                    0x00000001875a67d0 _dispatch_worker_thread3 + 120
8   libsystem_pthread.dylib              0x000000018779f100 _pthread_wqthread + 1092
9   libsystem_pthread.dylib              0x000000018779ecac start_wqthread + 0


Thread 10:
0   libsystem_kernel.dylib               0x00000001876d9a88 __workq_kernreturn + 8
1   libsystem_pthread.dylib              0x000000018779ecac start_wqthread + 0


Thread 9 crashed with ARM-64 Thread State:
    pc: 0x000000018715d7f4     fp: 0x000000016e1aeca0     sp: 0x000000016e1aec90     x0: 0x0000000118dd9a00 
    x1: 0x000000018715c250     x2: 0x0000000000000018     x3: 0x0000000000000000     x4: 0x0000000000000000 
    x5: 0x0000000000000000     x6: 0x0000000000000000     x7: 0x0000000000000000     x8: 0x0000000000000000 
    x9: 0x000000000000fffe    x10: 0x00000000fffffffe    x11: 0x00000000c3000002    x12: 0x0000000000000002 
   x13: 0x00000000c3000001    x14: 0x0000000000000000    x15: 0xfffffff100000000    x16: 0xffffffffffffffe1 
   x17: 0x000000018f3409a0    x18: 0x0000000000000000    x19: 0x000000017304ad70    x20: 0x000000017187a000 
   x21: 0x0000000000000000    x22: 0x0000000170aec380    x23: 0x0000000000000014    x24: 0x00000001ae9b4480 
   x25: 0x000000017187a000    x26: 0x00000001ae9b4480    x27: 0x000000016e1af0e0    x28: 0x0000000000000000 
    lr: 0x00000001875eba68   cpsr: 0x0000000020000000

Replies

I think you're probably correct that this is an overrelease, but it's not easy to find out why. It sort of looks (from line 1 of the thread 9 backtrace) that the object being overreleased is a block (Obj-C) or closure (Swift). Since it's apparently a GCD queue thread, it may be the block queued on the thread was deallocated while it was still running.


I'd suggest you start looking closely at completion handlers and other things you execute on a dispatch queue.

I think you're probably correct that this is an overrelease …

I also concur. My experience with over-release problems is that the standard memory debugging tools, and specifically zombies, will often help you track down the problem.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"