iOS 8 crashing in a weird pattern

2019-07-16 00:19发布

问题:

I have spent over a ton of hours working on an app, it works perfectly on iOS 7, both on device and simulator. When I run it on iOS 8, it works perfectly on simulator. But for some reason, when I run it on my iOS 8 device, it starts crashing weirdly. If I implement CLLocation, the app will run smoothly for the first 5 times that I run it. Then it will crash the MOMENT I compile it for the next 5 times. After that 5 times, it starts compiling smoothly again. Then after 5 more times, it crashes on launch again, and the pattern continues. IE. 1, run. 2. run. 3. run. 4. run. 5. run. 6-10.crash on launch, 11-15, run. 16-20 crash

HOWEVER, when I remove CLLocation, the app runs smoothly, but crashes on every 3rd launch. IE. 1. run. 2. run. 3. crash. 4. run. 5. run 6. crash.

I have been banging my head against the wall for like days without sleep on this. Can someone please explain to me why? For every crash on launch, the only error the console outputs is NSDictionary unknown selector.

I don't want my app to get rejected if Apple reviewers happen to run it at one of the "crash times"

Console Bt

(lldb) bt
* thread #3: tid = 0x12646, 0x00000001983640a8 libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.root.default-qos', stop reason = breakpoint 1.1
    frame #0: 0x00000001983640a8 libobjc.A.dylib`objc_exception_throw
    frame #1: 0x0000000187d8d094 CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:] + 220
    frame #2: 0x0000000187d89e48 CoreFoundation`___forwarding___ + 928
    frame #3: 0x0000000187c8f08c CoreFoundation`_CF_forwarding_prep_0 + 92
    frame #4: 0x0000000188c4f0dc Foundation`-[NSString getExternalRepresentation:extendedAttributes:forWritingToURLOrPath:usingEncoding:error:] + 192
    frame #5: 0x0000000188c4f23c Foundation`writeStringToURLOrPath + 72
  * frame #6: 0x00000001000c9f1c Blurtalk`+[PFInternalUtils installationId](self=<unavailable>, _cmd=<unavailable>) + 340 at PFInternalUtils.m:307
    frame #7: 0x00000001000f0a94 Blurtalk`+[PFNetworkCommandRunner createRequest:](self=0x000000010027d1b8, _cmd=<unavailable>, command=0x0000000170056a70) + 268 at PFNetworkCommandRunner.m:61
    frame #8: 0x00000001000f1044 Blurtalk`+[PFNetworkCommandRunner runCommandAsync:inOperation:](self=0x000000010027d1b8, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>) + 196 at PFNetworkCommandRunner.m:132
    frame #9: 0x00000001000f1748 Blurtalk`+[PFRetryingCommandRunner runCommandAsync:inOperation:attemptsMade:delay:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>, attemptsMade=1, delay=<unavailable>) + 92 at PFRetryingCommandRunner.m:42
    frame #10: 0x00000001000f16bc Blurtalk`+[PFRetryingCommandRunner runCommandAsync:inOperation:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>) + 124 at PFRetryingCommandRunner.m:35
    frame #11: 0x00000001000f1f80 Blurtalk`+[PFCachedCommandRunner runCommandAsync:inOperation:cachePolicy:maxCacheAge:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>, cachePolicy=<unavailable>, maxCacheAge=<unavailable>) + 240 at PFCachedCommandRunner.m:82
    frame #12: 0x000000010009dcd8 Blurtalk`__48-[BFTask continueWithExecutor:withSuccessBlock:]_block_invoke(.block_descriptor=0x0000000170241e60, task=<unavailable>) + 200 at BFTask.m:335
    frame #13: 0x000000010009d730 Blurtalk`__41-[BFTask continueWithExecutor:withBlock:]_block_invoke_2(.block_descriptor=0x000000017807a340) + 32 at BFTask.m:287
    frame #14: 0x0000000100338f20 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #15: 0x0000000100338ee0 libdispatch.dylib`_dispatch_client_callout + 16
    frame #16: 0x00000001003459a0 libdispatch.dylib`_dispatch_root_queue_drain + 1272
    frame #17: 0x0000000100346f18 libdispatch.dylib`_dispatch_worker_thread3 + 132
    frame #18: 0x0000000198b852e4 libsystem_pthread.dylib`_pthread_wqthread + 816

回答1:

I have been able to reproduce and narrow down your crash using NSZombieEnabled.

My backtrace:

2014-12-30 14:58:26.997 Proto[1398:513570] *** -[CFString getExternalRepresentation:extendedAttributes:forWritingToURLOrPath:usingEncoding:error:]: message sent to deallocated instance 0x170e78fc0
(lldb) bt
* thread #7: tid = 0x7d622, 0x00000001864be440 CoreFoundation`___forwarding___ + 968, queue = 'com.apple.root.default-qos', stop reason = EXC_BREAKPOINT (code=1, subcode=0x1864be440)
  * frame #0: 0x00000001864be440 CoreFoundation`___forwarding___ + 968
    frame #1: 0x00000001863c2b6c CoreFoundation`_CF_forwarding_prep_0 + 92
    frame #2: 0x000000018738a83c Foundation`writeStringToURLOrPath + 72
    frame #3: 0x00000001002485bc Proto`+[PFInternalUtils installationId](self=<unavailable>, _cmd=<unavailable>) + 340 at PFInternalUtils.m:308
    frame #4: 0x000000010028a944 Proto`+[PFNetworkCommandRunner createRequest:](self=0x000000010054eea8, _cmd=<unavailable>, command=0x0000000170446990) + 308 at PFNetworkCommandRunner.m:62
    frame #5: 0x000000010028aef4 Proto`+[PFNetworkCommandRunner runCommandAsync:inOperation:](self=0x000000010054eea8, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>) + 196 at PFNetworkCommandRunner.m:133
    frame #6: 0x000000010028b5fc Proto`+[PFRetryingCommandRunner runCommandAsync:inOperation:attemptsMade:delay:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>, attemptsMade=1, delay=<unavailable>) + 92 at PFRetryingCommandRunner.m:42
    frame #7: 0x000000010028b570 Proto`+[PFRetryingCommandRunner runCommandAsync:inOperation:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>) + 124 at PFRetryingCommandRunner.m:35
    frame #8: 0x000000010028be40 Proto`+[PFCachedCommandRunner runCommandAsync:inOperation:cachePolicy:maxCacheAge:](self=<unavailable>, _cmd=<unavailable>, command=<unavailable>, operation=<unavailable>, cachePolicy=<unavailable>, maxCacheAge=<unavailable>) + 248 at PFCachedCommandRunner.m:83
    frame #9: 0x00000001001ad038 Proto`__48-[BFTask continueWithExecutor:withSuccessBlock:]_block_invoke(.block_descriptor=0x0000000170446ea0, task=<unavailable>) + 200 at BFTask.m:335
    frame #10: 0x00000001001aca90 Proto`__41-[BFTask continueWithExecutor:withBlock:]_block_invoke_2(.block_descriptor=0x0000000171067b40) + 32 at BFTask.m:287
    frame #11: 0x0000000100ab8e30 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #12: 0x0000000100ab8df0 libdispatch.dylib`_dispatch_client_callout + 16
    frame #13: 0x0000000100ac59a0 libdispatch.dylib`_dispatch_root_queue_drain + 1280
    frame #14: 0x0000000100ac6f18 libdispatch.dylib`_dispatch_worker_thread3 + 132
    frame #15: 0x00000001974312e4 libsystem_pthread.dylib`_pthread_wqthread + 816

This is a bug in the Parse SDK, specifically when Parse tries to get device information on an initial install. I suggest you report this bug to Parse directly and point them to this StackOverflow question.

Additional conversation here: Parse Objective C library crashes on [PFInternalUtils installationId]

EDIT: There is an open bug report for this issue here: https://developers.facebook.com/bugs/1548203598729083



回答2:

you should create an one for all breakpoint that will stop on any exception, please read this article, it is a very useful technique. http://blog.manbolo.com/2012/01/23/xcode-tips-1-break-on-exceptions

by the way, NSDictionary does not have length, it seems like you made a mistake by confusing it with a NSString object.