如何在AQClient线程中追踪iPad应用程序的奇怪崩溃?

时间:2011-11-08 18:50:34

标签: iphone ios crash

我的应用程序最近开始显示奇怪的崩溃,我无法追踪到源。任何寻求帮助的帮助都会有所帮助:)

来自设备(iOS 5 iPad)的崩溃日志在开头显示以下内容:

Date/Time:       2011-11-08 19:07:21.044 +0100
OS Version:      iPhone OS 5.0 (9A334)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x406cad3d
Crashed Thread:  9

崩溃的线程9是AQClient线程,其堆栈跟踪如下所示:

Thread 9 name:  AQClient
Thread 9 Crashed:
0   libobjc.A.dylib                 0x30107fbc objc_msgSend + 16
1   AVFoundation                    0x3420cdc8 _ZL27AudioPlayerAQOutputCallbackPvP16OpaqueAudioQueueP16AudioQueueBuffer + 28
2   AudioToolbox                    0x32a409fe ClientMessageHandler::OutputBufferComplete(unsigned int) + 98
3   AudioToolbox                    0x32a425d6 AQClientCallbackMessageReader::DispatchCallbacks(unsigned char*, unsigned int, void*, unsigned int) + 198
4   AudioToolbox                    0x32a408dc AQCallbackReceiver_CallbackNotificationsAvailable + 364
5   AudioToolbox                    0x329ee4b6 _XCallbackNotificationsAvailable + 54
6   AudioToolbox                    0x329e436c mshMIGPerform + 368
7   CoreFoundation                  0x34fa454c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
8   CoreFoundation                  0x34fa44ee __CFRunLoopDoSource1 + 134
9   CoreFoundation                  0x34fa333c __CFRunLoopRun + 1364
10  CoreFoundation                  0x34f264d6 CFRunLoopRunSpecific + 294
11  CoreFoundation                  0x34f2639e CFRunLoopRunInMode + 98
12  AudioToolbox                    0x32a3d29c GenericRunLoopThread::Entry(void*) + 116
13  AudioToolbox                    0x329c5aac CAPThread::Entry(CAPThread*) + 208
14  libsystem_c.dylib               0x35756c16 _pthread_start + 314
15  libsystem_c.dylib               0x35756ad0 thread_start + 0

这似乎与AVAudioPlayer或MPMoviePlayer活动有关。在应用程序中我有一个电影播放(来自应用程序包的.m4v),然后当它完成时视图翻转到一边没有电影和音频开始播放。

在崩溃的情况下,我能听到的是同样的音频播放两次,即使它不是有意的。然后在完成音频时(当应该释放AVAudioPlayer时)应用程序崩溃。

我在应用中添加了一些NSLog来跟踪这里发生的事情。关键时刻的控制台向我展示了这样的事情:

Nov  8 19:17:19 unknown XXX[1753] <Warning>: Finished movie
Nov  8 19:17:19 unknown XXX[1753] <Warning>: Finished movie
Nov  8 19:17:20 unknown XXX[1753] <Warning>: flipping
Nov  8 19:17:20 unknown XXX[1753] <Warning>: flipping
Nov  8 19:17:20 unknown XXX[1753] <Warning>: --> dealloc <AVAudioPlayer: 0x6887530> (d2_s3_l3_q9.aif)
Nov  8 19:17:20 unknown XXX[1753] <Warning>: --> dealloc <AVAudioPlayer: 0x6887530> (d2_s3_l3_q9.aif)
Nov  8 19:17:20 unknown UIKitApplication:com.bundle.name[0x2432][1753] <Notice>: objc[1753]: Object 0x68859f0 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Nov  8 19:17:20 unknown UIKitApplication:com.bundle.name[0x2432][1753] <Notice>: objc[1753]: Object 0x11ef30 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Nov  8 19:17:20 unknown UIKitApplication:com.bundle.name[0x2432][1753] <Notice>: objc[1753]: Object 0x1a6720 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Nov  8 19:17:20 unknown UIKitApplication:com.bundle.name[0x2432][1753] <Notice>: objc[1753]: Object 0x6872400 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

(...) 

Nov  8 19:17:20 unknown UIKitApplication:com.bundle.name[0x2432][1753] <Notice>: objc[1753]: Object 0x6872ed0 of class __NSCFDictionary autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Nov  8 19:17:20 unknown UIKitApplication:com.bundle.name[0x2432][1753] <Notice>: objc[1753]: Object 0x10cf80 of class __NSCFNumber autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Nov  8 19:17:20 unknown UIKitApplication:com.bundle.name[0x2432][1753] <Notice>: objc[1753]: Object 0x6850480 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Nov  8 19:17:20 unknown UIKitApplication:com.bundle.name[0x2432][1753] <Notice>: objc[1753]: Object 0x10a530 of class __NSCFNumber autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Nov  8 19:17:20 unknown UIKitApplication:com.bundle.name[0x2432][1753] <Notice>: objc[1753]: Object 0x1d15d0 of class __NSCFNumber autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Nov  8 19:17:20 unknown UIKitApplication:com.bundle.name[0x2432][1753] <Notice>: objc[1753]: Object 0x6884550 of class TFCrashHandler autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Nov  8 19:17:20 unknown UIKitApplication:com.bundle.name[0x2432][1753] <Notice>: objc[1753]: Object 0x685ec10 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Nov  8 19:17:20 unknown UIKitApplication:com.bundle.name[0x2432][1753] <Notice>: objc[1753]: Object 0x6856270 of class __NSCFDictionary autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
Nov  8 19:17:21 unknown com.apple.networkd[1763] <Notice>: main:212 networkd.1763 built Sep 16 2011 00:02:59
Nov  8 19:17:25 unknown ReportCrash[1764] <Notice>: Formulating crash report for process XXX[1753]
Nov  8 19:17:25 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.bundle.name[0x2432]) Job appears to have crashed: Segmentation fault: 11
Nov  8 19:17:25 unknown SpringBoard[15] <Warning>: Application 'XXX' exited abnormally with signal 11: Segmentation fault: 11
Nov  8 19:17:25 unknown ReportCrash[1764] <Error>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/XXX_2011-11-08-191724_iKotapad.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0

编辑:

我认为,这里的关键部分是开头的加倍日志。非崩溃时,它只显示一次。而且,问题可能来自于调用同一对象的dealloc方法两次。

2 个答案:

答案 0 :(得分:1)

我在iOS5模拟器中运行的iPhone应用程序遇到了类似的问题。显然,通过这个设置,如果你有一个没有定义自动释放池的自动释放对象,系统将立即释放该对象并打印出该消息:“...类TheClass的对象0x6872ed0自动释放,没有池到位 - 只是泄漏 - 打破objc_autoreleaseNoPool()进行调试“。在我的代码中,它甚至在变量赋值之前释放了对象,所以我确保在该行之后有坏内存。要修复,你需要提供一个自动释放池...你可以用@autoreleasepool {...}包装分配这些对象的代码(在适当的任何级别),例如:

@autoreleasepool {
    NSData *data = [NSData dataWithBytes:myBytes length:myLength];
    //do something with data
}

通过使用@autoreleasepool定义自动释放池,它将保留该数据对象(不尝试并释放它),然后再使用该对象。

另一种解决方案是使用不使用自动释放的方法分配正在释放的对象。我知道NSData,[NSData data]将返回一个自动释放的对象,而[[NSData alloc] init]则不会。可能与您正在使用的对象类似。如果你控制分配,这显然只是一种可能性......如果不是,你可能会卡住定义一个自动释放池。

答案 1 :(得分:0)

这可能只发生在模拟器中。我遇到了一个类似的问题,我无法解决,但发现它只在模拟器中发生,在所有设备上运行良好。