异常类型:EXC_CRASH(SIGABRT)由nanozone_error引起

时间:2015-07-29 05:33:52

标签: ios crash

我正在开发一个APP,它有时因nanozone_error而崩溃 App监视AVAudioSessionRouteChangeNotification,然后执行相应的操作,如调用[AVAudioSession currentRoute],但有时,它在调用此方法时崩溃,而iOS内部由于nanozone_error。我很困惑。有人能帮助我吗?

Incident Identifier: 
CrashReporter Key:   
Hardware Model:      iPhone7,1
Process:             MyAPP 
Path:                
Identifier:          
Version:             
Code Type:           ARM-64 (Native)
Parent Process:      launchd [1]

Date/Time:           
Launch Time:         
OS Version:          iOS 8.4 (12H143)
Report Version:      105

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  26


Thread 26 name:  AVAudioSession Notify Thread
Thread 26 Crashed:
0   libsystem_kernel.dylib          0x0000000197187270 __pthread_kill + 8
1   libsystem_pthread.dylib         0x000000019722516c pthread_kill + 108
2   libsystem_c.dylib               0x00000001970feb14 abort + 108
3   libsystem_malloc.dylib          0x00000001971c23e0 nanozone_error + 316
4   libsystem_malloc.dylib          0x00000001971c254c _nano_malloc_check_clear + 360
5   libsystem_malloc.dylib          0x00000001971c1060 nano_malloc + 40
6   libsystem_malloc.dylib          0x00000001971b13e0 malloc_zone_malloc + 112
7   CoreFoundation                  0x0000000184bcae04 _CFRuntimeCreateInstance + 372
8   CoreFoundation                  0x0000000184bcbb04 CFBasicHashCreate + 108
9   CoreFoundation                  0x0000000184bcba28 CFDictionaryCreateMutable + 192
10  CoreFoundation                  0x0000000184c126a0 parseXMLElement + 2760
11  CoreFoundation                  0x0000000184c14220 getContentObject + 800
12  CoreFoundation                  0x0000000184c120c0 parseXMLElement + 1256
13  CoreFoundation                  0x0000000184c11a34 _CFPropertyListCreateFromUTF8Data + 2680
14  CoreFoundation                  0x0000000184bcb2a4 _CFPropertyListCreateWithData + 492
15  CoreFoundation                  0x0000000184bf7458 CFPropertyListCreateWithData + 100
16  AudioToolbox                    0x0000000184394c70 CADeserializer::ReadPlist() + 224
17  AudioToolbox                    0x0000000184288b6c MarshalCFPropertyList::DeserializeT(CADeserializer&, void const*&) + 28
18  AudioToolbox                    0x0000000184288ab0 TMarshaller<void const*>::Deserialize(CADeserializer&, void*&, unsigned int&) + 132
19  AudioToolbox                    0x00000001843ba6f0 PropertyMarshaller::Deserialize(unsigned int, void*&, unsigned int&, PropertyMarshaller::EClientServer) + 132
20  AudioToolbox                    0x00000001841e55a0 AudioSessionGetProperty + 620
21  libAVFAudio.dylib               0x0000000183644568 int GetProperty<__CFDictionary const*>(unsigned int, __CFDictionary const**) + 60
22  libAVFAudio.dylib               0x0000000183642460 -[AVAudioSession currentRoute] + 36
23  MyAPP                             0x000000010061bd88 -[MyAudioSession getCurrentOutputRoute] + 196

1 个答案:

答案 0 :(得分:2)

不幸的是,当你点击nanozone_error时,堆栈跟踪不会告诉你很多,因为真正的问题发生在其他地方。这里发生的是malloc_zone_malloc()试图分配一块内存,但失败了。它失败了,因为_nano_malloc_check_clear()对新分配的块执行了大量检查,发现不一致并抛出nanozone_error。参见:

https://opensource.apple.com/source/libmalloc/libmalloc-53.1.1/src/nano_malloc.c

可能发生的事情是在释放并返回堆后修改了内存块,即它没有被正确保留。找到过度发布(或保留不足)的好方法是在调试时设置NSZombieEnabled环境变量。在调试方案中,转到&#34;诊断&#34;选项卡并检查&#34; Zombie Objects&#34;。这不会取消分配内存块,而是将它们变成&#34; zombies&#34;,这些对象只会阻止任何试图访问它们的东西。当然,这会导致内存消耗得非常快,所以它不应该永久保留。欲了解更多信息: https://gist.github.com/JeOam/e62c95a0b4c21974bcf6