为什么这个应用程序在后台崩溃?

时间:2010-12-23 01:55:23

标签: iphone objective-c gps core-location background-process

我的应用使用背景位置进行GPS更新。我已经注册了它的背景位置更新,当它在后台运行时,它总是像这样崩溃。

由于我没有编写大部分代码,我真的不知道发生了什么。

我检查了内存分配,但似乎没有太多问题。这是一份崩溃报告:

Incident Identifier: 39F6F622-1274-4B6C-BA19-32D10E04E309
CrashReporter Key:   4757f4c5e5f009daf18eb0c512f729356c3e5de4
Hardware Model:      iPhone3,1
Process:         Get Off Now! [3040]
Path:            /var/mobile/Applications/43D41F77-B225-4F47-AFB0-D2F2E00E18DF/Get Off Now!.app/Get Off Now!
Identifier:      Get Off Now!
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2010-12-22 13:31:29.293 +0800
OS Version:      iPhone OS 4.1 (8B117)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000d
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                 0x000027d8 objc_msgSend + 16
1   CoreFoundation                  0x000042ae CFRetain + 62
2   CoreFoundation                  0x0005ab58 CFMessagePortInvalidate + 304
3   CoreFoundation                  0x0005b05e CFMessagePortIsValid + 42
4   CoreLocation                    0x000030f8 CLClientIsValid + 12
5   CoreLocation                    0x00004b10 CLClientSendAndCache(__CLClient*, CLDaemonCommType, void*, int, unsigned char, unsigned char) + 40
6   CoreLocation                    0x000051cc CLClientHandleWatchdogTimerExpiry(__CFRunLoopTimer*, void*) + 24
7   CoreFoundation                  0x000567f4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
8   CoreFoundation                  0x000562a6 __CFRunLoopDoTimer + 854
9   CoreFoundation                  0x0002779e __CFRunLoopRun + 1082
10  CoreFoundation                  0x00027270 CFRunLoopRunSpecific + 224
11  CoreFoundation                  0x00027178 CFRunLoopRunInMode + 52
12  GraphicsServices                0x000045ec GSEventRunModal + 108
13  GraphicsServices                0x00004698 GSEventRun + 56
14  UIKit                           0x0000411c -[UIApplication _run] + 396
15  UIKit                           0x00002128 UIApplicationMain + 664
16  Get Off Now!                    0x00002406 0x1000 + 5126
17  Get Off Now!                    0x000023d0 0x1000 + 5072

Thread 1:
0   libSystem.B.dylib               0x0002d330 kevent + 24
1   libSystem.B.dylib               0x000d6b6c _dispatch_mgr_invoke + 88
2   libSystem.B.dylib               0x000d65bc _dispatch_queue_invoke + 96
3   libSystem.B.dylib               0x000d675c _dispatch_worker_thread2 + 120
4   libSystem.B.dylib               0x0007a67a _pthread_wqthread + 258
5   libSystem.B.dylib               0x00073190 start_wqthread + 0

Thread 2:
0   libSystem.B.dylib               0x00000cf4 semaphore_wait_signal_trap + 8
1   libSystem.B.dylib               0x0002e4ee semaphore_wait_signal + 2
2   libSystem.B.dylib               0x00002ae4 pthread_mutex_lock + 248
3   WebCore                         0x00002620 _WebTryThreadLock(bool) + 140
4   WebCore                         0x00002566 WebRunLoopLock(__CFRunLoopObserver*, unsigned long, void*) + 18
5   CoreFoundation                  0x00030236 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 10
6   CoreFoundation                  0x000300aa __CFRunLoopDoObservers + 406
7   CoreFoundation                  0x000276c0 __CFRunLoopRun + 860
8   CoreFoundation                  0x00027270 CFRunLoopRunSpecific + 224
9   CoreFoundation                  0x00027178 CFRunLoopRunInMode + 52
10  WebCore                         0x000024e2 RunWebThread(void*) + 362
11  libSystem.B.dylib               0x0007a27e _pthread_start + 242
12  libSystem.B.dylib               0x0006f2a8 thread_start + 0

Thread 3:
0   libSystem.B.dylib               0x0007b19c __workq_kernreturn + 8
1   libSystem.B.dylib               0x0007a790 _pthread_wqthread + 536
2   libSystem.B.dylib               0x00073190 start_wqthread + 0

Thread 4:
0   libSystem.B.dylib               0x0007b19c __workq_kernreturn + 8
1   libSystem.B.dylib               0x0007a790 _pthread_wqthread + 536
2   libSystem.B.dylib               0x00073190 start_wqthread + 0

Thread 0 crashed with ARM Thread State:
    r0: 0x001a01c0    r1: 0x33024270      r2: 0x00000005      r3: 0x3002d7c9
    r4: 0x00000005    r5: 0x3e1af5e4      r6: 0x00000017      r7: 0x2fffeac0
    r8: 0x00000004    r9: 0x001fc098     r10: 0x00855864     r11: 0x2fffeb48
    ip: 0x3e19c3f0    sp: 0x2fffeaa8      lr: 0x307fc2b5      pc: 0x3002d7d8
  cpsr: 0x20000030

这是崩溃的另一种方式;它看起来是一样的,除了它长时间使用100%的CPU:

Incident Identifier: 61B42F36-021F-48D2-B180-112527BAE5CF
CrashReporter Key:   4757f4c5e5f009daf18eb0c512f729356c3e5de4
Hardware Model:      iPhone3,1
Process:         Get Off Now! [3751]
Path:            /var/mobile/Applications/43D41F77-B225-4F47-AFB0-D2F2E00E18DF/Get Off Now!.app/Get Off Now!
Identifier:      Get Off Now!
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2010-12-23 13:06:50.363 +0800
OS Version:      iPhone OS 4.1 (8B117)
Report Version:  104

Exception Type:  00000020
Exception Codes: 0x8badf00d
Highlighted Thread:  0

Application Specific Information:
Get Off Now![3751] has active assertions beyond permitted time: 
{(
    <SBProcessAssertion: 0xca2a8a0> identifier: CoreLocationRegistration process: Get Off Now![3751] permittedBackgroundDuration: 600.000000 reason: finishTask owner pid:3751 preventSuspend  preventIdleSleep 
)}

Elapsed total CPU time (seconds): 600.010 (user 19.350, system 580.660), 100% CPU 
Elapsed application CPU time (seconds): 575.320, 96% CPU

Thread 0:
0   libSystem.B.dylib               0x00004f0c OSSpinLockLock + 44
1   CoreFoundation                  0x0005aa42 CFMessagePortInvalidate + 26
2   CoreFoundation                  0x0005b05e CFMessagePortIsValid + 42
3   CoreLocation                    0x000030f8 CLClientIsValid + 12
4   CoreLocation                    0x00004b10 CLClientSendAndCache(__CLClient*, CLDaemonCommType, void*, int, unsigned char, unsigned char) + 40
5   CoreLocation                    0x000051cc CLClientHandleWatchdogTimerExpiry(__CFRunLoopTimer*, void*) + 24
6   CoreFoundation                  0x000567f4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
7   CoreFoundation                  0x000562a6 __CFRunLoopDoTimer + 854
8   CoreFoundation                  0x0002779e __CFRunLoopRun + 1082
9   CoreFoundation                  0x00027270 CFRunLoopRunSpecific + 224
10  CoreFoundation                  0x00027178 CFRunLoopRunInMode + 52
11  GraphicsServices                0x000045ec GSEventRunModal + 108
12  GraphicsServices                0x00004698 GSEventRun + 56
13  UIKit                           0x0000411c -[UIApplication _run] + 396
14  UIKit                           0x00002128 UIApplicationMain + 664
15  Get Off Now!                    0x000022de main (main.m:13)
16  Get Off Now!                    0x000022a8 start + 32

Thread 1:
0   libSystem.B.dylib               0x0002d330 kevent + 24
1   libSystem.B.dylib               0x000d6b6c _dispatch_mgr_invoke + 88
2   libSystem.B.dylib               0x000d65bc _dispatch_queue_invoke + 96
3   libSystem.B.dylib               0x000d675c _dispatch_worker_thread2 + 120
4   libSystem.B.dylib               0x0007a67a _pthread_wqthread + 258
5   libSystem.B.dylib               0x00073190 start_wqthread + 0

Thread 2:
0   libSystem.B.dylib               0x00000c98 mach_msg_trap + 20
1   libSystem.B.dylib               0x00002d64 mach_msg + 44
2   CoreFoundation                  0x00027c38 __CFRunLoopServiceMachPort + 88
3   CoreFoundation                  0x000274c2 __CFRunLoopRun + 350
4   CoreFoundation                  0x00027270 CFRunLoopRunSpecific + 224
5   CoreFoundation                  0x00027178 CFRunLoopRunInMode + 52
6   WebCore                         0x000024e2 RunWebThread(void*) + 362
7   libSystem.B.dylib               0x0007a27e _pthread_start + 242
8   libSystem.B.dylib               0x0006f2a8 thread_start + 0

Unknown thread crashed with unknown flavor: 5, state_count: 1

2 个答案:

答案 0 :(得分:1)

我认为你需要检查一些由其他线程发布的对象,但它们是由主线程访问的。我遇到过这样的事情,因为我访问了一些已经发布的对象。

答案 1 :(得分:0)

我生成了完全相同的崩溃日志。我有一个主线程,它使用NSOperationQueue生成数据下载线程,然后在完成时使用performSelectorOnMainThread。

在我的didupdatelocation方法中,我在数组中循环,在某些情况下启动本地通知。它似乎在本地通知的SECOND实例上失败(对于相同的数组项),但我不能确定。我确实试过象征日志,但4.2.1中有一些丢失的文件错误,所以我复制了4.2中的符号,并且无法使用atos(但这可能是我的错)。

昨晚,我做了以下更改,似乎所有这些都得到了解决:

1)将所有self.locationManager表示法更改为只是locationManager

2)从appdelegate中的dealloc方法中删除了所有内容(除了super)