我的ios应用程序使用了大量的核心数据和核心动画。由于多线程,它有时会以不可复制的方式崩溃。任何编程忍者都可以帮助调查此崩溃问题吗?我不知道我的空mutablearray
被称为objectAtIndex
。
此外,我不知道如何跟踪发生CGContext
错误的位置。由于它不是NSException
,我不知道如何在那里设置断点。任何人都可以教我如何在出现CGContext
错误时设置断点吗?
我的控制台日志:
May 30 09:12:39 Dons-iPod-touch larklife[6914] <Warning>: EventsViewController.m 680: indexPath in finish block<NSIndexPath 0x1f18fe60> 2 indexes [1, 0]
May 30 09:12:39 Dons-iPod-touch larklife[6914] <Error>: CGContextSetFillColorWithColor: invalid context 0x0
May 30 09:12:39 Dons-iPod-touch larklife[6914] <Error>: CGContextSaveGState: invalid context 0x0
May 30 09:12:39 Dons-iPod-touch larklife[6914] <Error>: CGContextSetFlatness: invalid context 0x0
May 30 09:12:39 Dons-iPod-touch larklife[6914] <Error>: CGContextAddPath: invalid context 0x0
May 30 09:12:39 Dons-iPod-touch larklife[6914] <Error>: CGContextDrawPath: invalid context 0x0
May 30 09:12:39 Dons-iPod-touch larklife[6914] <Error>: CGContextRestoreGState: invalid context 0x0
May 30 09:12:40 Dons-iPod-touch larklife[6914] <Error>: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x330e92a3 0x3ad6797f 0x33034b75 0x32f5bc0d 0xeb555 0xe5c9b 0x106549 0xe1521 0xebcad 0xde557 0xe4589 0xe5275 0x24b06d 0x339f7277 0x330be5df 0x330be291 0x330bcf01 0x3302febd 0x3302fd49 0x36be22eb 0x34f45301 0x206fd 0x3b19eb20)
崩溃报告:
Incident Identifier: C18D4D70-7157-4456-900B-077BDE488A70
CrashReporter Key: 7531fede04c2aea4fcfb40a804a8e2fdb0a4cb79
Hardware Model: iPod4,1
Process: larklife [6914]
Path: /var/mobile/Applications/30FAAA4E-1FC4-452F-82E2- 1E706A34A0B8/larklife.app/larklife
Identifier: larklife
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2013-05-30 09:12:40.483 -0700
OS Version: iOS 6.1.3 (10B329)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x330e929e __exceptionPreprocess + 158
1 libobjc.A.dylib 0x3ad6797a objc_exception_throw + 26
2 CoreFoundation 0x33034b70 -[__NSArrayM objectAtIndex:] + 160
3 CoreData 0x32f5bc08 -[NSFetchedResultsController objectAtIndexPath:] + 236
4 larklife 0x000eb550 0x19000 + 861520
5 larklife 0x000e5c96 0x19000 + 838806
6 larklife 0x00106544 0x19000 + 972100
7 larklife 0x000e151c 0x19000 + 820508
8 larklife 0x000ebca8 0x19000 + 863400
9 larklife 0x000de552 0x19000 + 808274
10 larklife 0x000e4584 0x19000 + 832900
11 larklife 0x000e5270 0x19000 + 836208
12 larklife 0x0024b068 0x19000 + 2302056
13 Foundation 0x339f7272 __NSFireDelayedPerform + 446
14 CoreFoundation 0x330be5da __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 10
15 CoreFoundation 0x330be28c __CFRunLoopDoTimer + 268
16 CoreFoundation 0x330bcefc __CFRunLoopRun + 1228
17 CoreFoundation 0x3302feb8 CFRunLoopRunSpecific + 352
18 CoreFoundation 0x3302fd44 CFRunLoopRunInMode + 100
19 GraphicsServices 0x36be22e6 GSEventRunModal + 70
20 UIKit 0x34f452fc UIApplicationMain + 1116
21 larklife 0x000206f8 0x19000 + 30456
22 libdyld.dylib 0x3b19eb1c start + 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3b265350 __pthread_kill + 8
1 libsystem_c.dylib 0x3b1dc11e pthread_kill + 54
2 libsystem_c.dylib 0x3b21896e abort + 90
3 libc++abi.dylib 0x3a7b6d4a abort_message + 70
4 libc++abi.dylib 0x3a7b3ff4 _ZL17default_terminatev + 20
5 libobjc.A.dylib 0x3ad67a74 _ZL15_objc_terminatev + 144
6 libc++abi.dylib 0x3a7b4078 _ZL19safe_handler_callerPFvvE + 76
7 libc++abi.dylib 0x3a7b4110 std::terminate() + 16
8 libc++abi.dylib 0x3a7b5594 __cxa_rethrow + 84
9 libobjc.A.dylib 0x3ad679cc objc_exception_rethrow + 8
10 CoreFoundation 0x3302ff1c CFRunLoopRunSpecific + 452
11 CoreFoundation 0x3302fd44 CFRunLoopRunInMode + 100
12 GraphicsServices 0x36be22e6 GSEventRunModal + 70
13 UIKit 0x34f452fc UIApplicationMain + 1116
14 larklife 0x000206f8 0x19000 + 30456
15 libdyld.dylib 0x3b19eb1c start + 0
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x3b255648 kevent64 + 24
1 libdispatch.dylib 0x3b18e4ec _dispatch_mgr_invoke + 792
2 libdispatch.dylib 0x3b180df4 _dispatch_mgr_thread$VARIANT$up + 32
Thread 2 name: WebThread
Thread 2:
0 libsystem_kernel.dylib 0x3b254eb4 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3b255048 mach_msg + 36
2 CoreFoundation 0x330be040 __CFRunLoopServiceMachPort + 124
3 CoreFoundation 0x330bcd9e __CFRunLoopRun + 878
4 CoreFoundation 0x3302feb8 CFRunLoopRunSpecific + 352
5 CoreFoundation 0x3302fd44 CFRunLoopRunInMode + 100
6 WebCore 0x3901d500 _ZL12RunWebThreadPv + 440
7 libsystem_c.dylib 0x3b1be30e _pthread_start + 306
8 libsystem_c.dylib 0x3b1be1d4 thread_start + 4
Thread 3:
0 libsystem_kernel.dylib 0x3b265d98 __workq_kernreturn + 8
1 libsystem_c.dylib 0x3b1b3cf6 _pthread_workq_return + 14
2 libsystem_c.dylib 0x3b1b3a12 _pthread_wqthread + 362
3 libsystem_c.dylib 0x3b1b38a0 start_wqthread + 4
Thread 4:
0 libsystem_kernel.dylib 0x3b265d98 __workq_kernreturn + 8
1 libsystem_c.dylib 0x3b1b3cf6 _pthread_workq_return + 14
2 libsystem_c.dylib 0x3b1b3a12 _pthread_wqthread + 362
3 libsystem_c.dylib 0x3b1b38a0 start_wqthread + 4
Thread 5 name: com.apple.NSURLConnectionLoader
Thread 5:
0 libsystem_kernel.dylib 0x3b254eb4 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3b255048 mach_msg + 36
2 CoreFoundation 0x330be040 __CFRunLoopServiceMachPort + 124
3 CoreFoundation 0x330bcd9e __CFRunLoopRun + 878
4 CoreFoundation 0x3302feb8 CFRunLoopRunSpecific + 352
5 CoreFoundation 0x3302fd44 CFRunLoopRunInMode + 100
6 Foundation 0x3397c3d0 +[NSURLConnection(Loader) _resourceLoadLoop:] + 304
7 Foundation 0x339ffe80 __NSThread__main__ + 968
8 libsystem_c.dylib 0x3b1be30e _pthread_start + 306
9 libsystem_c.dylib 0x3b1be1d4 thread_start + 4
Thread 6 name: com.apple.CFSocket.private
Thread 6:
0 libsystem_kernel.dylib 0x3b265594 __select + 20
1 CoreFoundation 0x330c21f2 __CFSocketManager + 674
2 libsystem_c.dylib 0x3b1be30e _pthread_start + 306
3 libsystem_c.dylib 0x3b1be1d4 thread_start + 4
Thread 7 name: Dispatch queue: NSManagedObjectContext Queue
Thread 7:
0 CoreData 0x32ebe19c _kvcPropertysPrimitiveSetters + 0
1 CoreData 0x32edc700 _sharedIMPL_setvfk_core + 44
2 larklife 0x000ba374 0x19000 + 660340
3 CoreData 0x32ed0bf0 _PF_Handler_Public_SetProperty + 88
4 CoreData 0x32ed312a -[NSManagedObject setValue:forKey:] + 86
5 larklife 0x002314f2 0x19000 + 2196722
6 larklife 0x00060ed8 0x19000 + 294616
7 CoreFoundation 0x330dd99e __NSArrayEnumerate + 394
8 CoreFoundation 0x3303fb66 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 58
9 larklife 0x00060d44 0x19000 + 294212
10 larklife 0x0005d204 0x19000 + 279044
11 CoreData 0x32ee6072 developerSubmittedBlockToNSManagedObjectContextPerform_privateasync + 66
12 libdispatch.dylib 0x3b17e996 _dispatch_queue_drain$VARIANT$up + 142
13 libdispatch.dylib 0x3b17e890 _dispatch_queue_invoke$VARIANT$up + 32
14 libdispatch.dylib 0x3b18d212 _dispatch_root_queue_drain + 190
15 libdispatch.dylib 0x3b18d3b4 _dispatch_worker_thread2 + 80
16 libsystem_c.dylib 0x3b1b3a0e _pthread_wqthread + 358
17 libsystem_c.dylib 0x3b1b38a0 start_wqthread + 4
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x00000000 r1: 0x00000000 r2: 0x00000000 r3: 0x3cd16534
r4: 0x00000006 r5: 0x3cd16b88 r6: 0x1f483d54 r7: 0x2fde7a04
r8: 0x1f483d30 r9: 0x00000400 r10: 0x00000000 r11: 0x00000000
ip: 0x00000148 sp: 0x2fde79f8 lr: 0x3b1dc123 pc: 0x3b265350
cpsr: 0x00080010
答案 0 :(得分:1)
你的错误信息说:
[__ NSArrayM objectAtIndex:]:超出边界的索引0
。原因可能是使用NSMUtableArray
(__NSArrayM
)并非线程安全,请参阅here。
如果没有提供任何代码,我建议您仔细阅读引用的线程编程指南,并相应地更正您的代码。
答案 1 :(得分:1)
在events viewcontroller.m
中,您在索引0和1处使用的数组为空。检查代码的160和236是否存在产生的错误。这肯定与获取数据有关。它似乎无法从您的商店获取数据。这是我在没有看到实际代码的情况下收集的内容。
答案 2 :(得分:1)
你试图得到一个空数组的第一个元素,它产生崩溃,异常是自我解释的。
当应用程序使用po
命令(打印对象)崩溃时,您可以调试数组:
po the_array_object
另外,请确保在断点导航器中设置断点ON
,以便从编译器中获得更好的调试。