Question

I just uploaded an app to the appstore, it was developed for ios7.

They rejected the app because of a crash I can't reproduce... They sent me this crash report:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000008
Triggered by Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x000000018e0501c8 objc_msgSend + 8
1   UIKit                           0x000000018493e940 __97-[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:]_block_invoke718 + 52
2   UIKit                           0x00000001846b6504 -[UIViewController _executeAfterAppearanceBlock] + 60
3   UIKit                           0x00000001846b646c _applyBlockToCFArrayCopiedToStack + 352
4   UIKit                           0x00000001846224c8 _afterCACommitHandler + 540
5   CoreFoundation                  0x00000001816270a4 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28
6   CoreFoundation                  0x000000018162432c __CFRunLoopDoObservers + 368
7   CoreFoundation                  0x00000001816246b8 __CFRunLoopRun + 760
8   CoreFoundation                  0x00000001815656cc CFRunLoopRunSpecific + 448
9   GraphicsServices                0x0000000187201c08 GSEventRunModal + 164
10  UIKit                           0x0000000184696fd8 UIApplicationMain + 1152
11  brandnooz                       0x00000001000aaa0c 0x100038000 + 469516
12  libdyld.dylib                   0x000000018e633a9c start + 0

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x000000018e715aa8 kevent64 + 8
1   libdispatch.dylib               0x000000018e619998 _dispatch_mgr_thread + 48

Thread 2 name:  AFNetworking
Thread 2:
0   libsystem_kernel.dylib          0x000000018e715ca0 mach_msg_trap + 8
1   CoreFoundation                  0x0000000181626570 __CFRunLoopServiceMachPort + 180
2   CoreFoundation                  0x0000000181624700 __CFRunLoopRun + 832
3   CoreFoundation                  0x00000001815656cc CFRunLoopRunSpecific + 448
4   Foundation                      0x00000001821012c0 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 292
5   Foundation                      0x000000018215ed74 -[NSRunLoop(NSRunLoop) run] + 92
6   brandnooz                       0x0000000100045280 0x100038000 + 53888
7   Foundation                      0x00000001821e8408 __NSThread__main__ + 996
8   libsystem_pthread.dylib         0x000000018e7afe18 _pthread_body + 164
9   libsystem_pthread.dylib         0x000000018e7afd70 _pthread_start + 136
10  libsystem_pthread.dylib         0x000000018e7ad550 thread_start + 0

Thread 3 name:  com.apple.NSURLConnectionLoader
Thread 3:
0   libsystem_kernel.dylib          0x000000018e715ca0 mach_msg_trap + 8
1   CoreFoundation                  0x0000000181626570 __CFRunLoopServiceMachPort + 180
2   CoreFoundation                  0x0000000181624700 __CFRunLoopRun + 832
3   CoreFoundation                  0x00000001815656cc CFRunLoopRunSpecific + 448
4   Foundation                      0x000000018215a424 +[NSURLConnection(Loader) _resourceLoadLoop:] + 344
5   Foundation                      0x00000001821e8408 __NSThread__main__ + 996
6   libsystem_pthread.dylib         0x000000018e7afe18 _pthread_body + 164
7   libsystem_pthread.dylib         0x000000018e7afd70 _pthread_start + 136
8   libsystem_pthread.dylib         0x000000018e7ad550 thread_start + 0

Thread 4 name:  com.apple.CFSocket.private
Thread 4:
0   libsystem_kernel.dylib          0x000000018e72e76c __select + 8
1   libsystem_pthread.dylib         0x000000018e7afe18 _pthread_body + 164
2   libsystem_pthread.dylib         0x000000018e7afd70 _pthread_start + 136
3   libsystem_pthread.dylib         0x000000018e7ad550 thread_start + 0

Thread 5 name:  Dispatch queue: com.apple.root.high-priority
Thread 5:
0   libsystem_kernel.dylib          0x000000018e72e394 __psynch_cvwait + 8
1   Foundation                      0x00000001821cf8e0 -[__NSOperationInternal _waitUntilFinished:] + 100
2   brandnooz                       0x0000000100083928 0x100038000 + 309544
3   brandnooz                       0x00000001000cf3c0 0x100038000 + 619456
4   libdispatch.dylib               0x000000018e618010 _dispatch_call_block_and_release + 20
5   libdispatch.dylib               0x000000018e617fd0 _dispatch_client_callout + 12
6   libdispatch.dylib               0x000000018e61f2b4 _dispatch_root_queue_drain + 552
7   libdispatch.dylib               0x000000018e61f4f8 _dispatch_worker_thread2 + 72
8   libsystem_pthread.dylib         0x000000018e7ad6b8 _pthread_wqthread + 352
9   libsystem_pthread.dylib         0x000000018e7ad548 start_wqthread + 0

Thread 6 name:  Dispatch queue: com.apple.root.default-priority
Thread 6:
0   libsystem_kernel.dylib          0x000000018e715cdc semaphore_wait_trap + 8
1   brandnooz                       0x00000001000d8044 0x100038000 + 655428
2   libdispatch.dylib               0x000000018e618010 _dispatch_call_block_and_release + 20
3   libdispatch.dylib               0x000000018e617fd0 _dispatch_client_callout + 12
4   libdispatch.dylib               0x000000018e61f2b4 _dispatch_root_queue_drain + 552
5   libdispatch.dylib               0x000000018e61f4f8 _dispatch_worker_thread2 + 72
6   libsystem_pthread.dylib         0x000000018e7ad6b8 _pthread_wqthread + 352
7   libsystem_pthread.dylib         0x000000018e7ad548 start_wqthread + 0

Thread 7 name:  Dispatch queue: com.apple.root.high-priority
Thread 7:
0   libsystem_kernel.dylib          0x000000018e72e394 __psynch_cvwait + 8
1   Foundation                      0x00000001821cf8e0 -[__NSOperationInternal _waitUntilFinished:] + 100
2   brandnooz                       0x0000000100083928 0x100038000 + 309544
3   brandnooz                       0x00000001000cf3c0 0x100038000 + 619456
4   libdispatch.dylib               0x000000018e618010 _dispatch_call_block_and_release + 20
5   libdispatch.dylib               0x000000018e617fd0 _dispatch_client_callout + 12
6   libdispatch.dylib               0x000000018e61f2b4 _dispatch_root_queue_drain + 552
7   libdispatch.dylib               0x000000018e61f4f8 _dispatch_worker_thread2 + 72
8   libsystem_pthread.dylib         0x000000018e7ad6b8 _pthread_wqthread + 352
9   libsystem_pthread.dylib         0x000000018e7ad548 start_wqthread + 0

Thread 8 name:  Dispatch queue: com.apple.root.default-priority
Thread 8:
0   libsystem_kernel.dylib          0x000000018e715cdc semaphore_wait_trap + 8
1   brandnooz                       0x00000001000d8044 0x100038000 + 655428
2   libdispatch.dylib               0x000000018e618010 _dispatch_call_block_and_release + 20
3   libdispatch.dylib               0x000000018e617fd0 _dispatch_client_callout + 12
4   libdispatch.dylib               0x000000018e61f2b4 _dispatch_root_queue_drain + 552
5   libdispatch.dylib               0x000000018e61f4f8 _dispatch_worker_thread2 + 72
6   libsystem_pthread.dylib         0x000000018e7ad6b8 _pthread_wqthread + 352
7   libsystem_pthread.dylib         0x000000018e7ad548 start_wqthread + 0

Thread 9 name:  Dispatch queue: com.apple.network.helper_queue
Thread 9:
0   libsystem_kernel.dylib          0x000000018e715ca0 mach_msg_trap + 8
1   libdispatch.dylib               0x000000018e621648 _dispatch_mach_msg_send + 364
2   libdispatch.dylib               0x000000018e61a6d4 dispatch_mach_send + 216
3   libxpc.dylib                    0x000000018e7c9814 xpc_connection_send_message_with_reply + 124
4   libsystem_network.dylib         0x000000018e77cfe0 __net_helper_send_block_invoke + 48
5   libdispatch.dylib               0x000000018e617fd0 _dispatch_client_callout + 12
6   libdispatch.dylib               0x000000018e61dc80 _dispatch_barrier_sync_f_invoke + 44
7   libsystem_network.dylib         0x000000018e77ab84 net_helper_send + 212
8   libsystem_network.dylib         0x000000018e77bd4c net_helper_connection_start + 264
9   libsystem_network.dylib         0x000000018e778b78 tcp_connection_register_reachability + 164
10  libsystem_network.dylib         0x000000018e77775c __tcp_connection_start_block_invoke + 312
11  libdispatch.dylib               0x000000018e618010 _dispatch_call_block_and_release + 20
12  libdispatch.dylib               0x000000018e617fd0 _dispatch_client_callout + 12
13  libdispatch.dylib               0x000000018e61e4a4 _dispatch_queue_drain + 636
14  libdispatch.dylib               0x000000018e61a4bc _dispatch_queue_invoke + 64
15  libdispatch.dylib               0x000000018e61f0f0 _dispatch_root_queue_drain + 100
16  libdispatch.dylib               0x000000018e61f4f8 _dispatch_worker_thread2 + 72
17  libsystem_pthread.dylib         0x000000018e7ad6b8 _pthread_wqthread + 352
18  libsystem_pthread.dylib         0x000000018e7ad548 start_wqthread + 0

Thread 10:
0   libsystem_kernel.dylib          0x000000018e72ee74 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x000000018e7ad548 start_wqthread + 0

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000008   x1: 0x0000000184d29a89   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x0000000000000000   x5: 0x0000000000000000   x6: 0x0000000000000000   x7: 0x0000000000000000
    x8: 0x000000018f24b4b8   x9: 0x0000000100183460  x10: 0x0000000150882c00  x11: 0x000000520000007f
   x12: 0x0000000150883390  x13: 0x000001a500183465  x14: 0x0000000000000006  x15: 0x0000000000000000
   x16: 0x000000018e0501c0  x17: 0x00000001846484ec  x18: 0x0000000000000000  x19: 0x0000000170053500
   x20: 0x000000018f287000  x21: 0x000000016fdc6b28  x22: 0x000000016fdc6b20  x23: 0x000000017012d3e0
   x24: 0x000000017012d3f0  x25: 0x000000019157a098  x26: 0x000000016fdc6b20  x27: 0x000000016fdc6d00
   x28: 0x0000000000000003  fp: 0x000000016fdc6af0   lr: 0x000000018493e944
    sp: 0x000000016fdc6ae0   pc: 0x000000018e0501c8 cpsr: 0x20000000

Please help me to solve this issue. Thanks In Advance

Was it helpful?

Solution

You crashed inside objc_msgSend with an EXC_BAD_ACCESS exception. In my experience this probably means that an object has gone out of scope and you're trying to access it or, the object is supposed to do something on another thread and in the mean time (while it's doing that), its gone out of scope on the original thread.

If you're using one of Apple's multithreaded objects (pretty much anything with delegate callbacks), make sure it is retained (strong-ly) by the object in which it is contained. For example if you're using an object with asynchronous callbacks, you can't just instantiate it inside a method and then let it disappear, you have to make it a strong @property so it remains in scope even when the method returns and you are awaiting the callbacks.

EDIT (Based on CFSocket thread):

By the look of it, you're using a socket API which is commonly used with the NSStream class. Remember to create strong @properties for those NSStream objects (or other connection objects you are using), and, if you're wrapping them inside another object, make sure that it is a strong @property of whichever object is using it. You can't get an asynchronous callback from an object that's not there anymore on the thread that created it.

(Note this is not just a case of messaging an object that has been set to nil. Messages to nil do not crash, they just return nil. The issue is a message being sent to something in memory that you don't own anymore).

EDIT 2 (based on main thread):

Are you sure you own every object that is being used in the View Controller transition? Creating a transient object in a block or asynchronous action could also be causing the EXC_BAD_ACCESS.

OTHER TIPS

From what it looks like, may be two threads are accessing the same variables where one of the threads is corrupting the variables used in the other. It is a synchronization issue. Bad access mostly means you are accessing a variable that is nil

You can integrate a crash reporting tool like www.crashlytics.com in your application. It is very easy to implement and the documentation is available once you download the sdk. After implementation, test your app throughly and it will tell you the exact lines where your code crashes and you can resolve it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top