有时我的 Cocoa 应用程序在尝试加载系统声音时崩溃。我自己无法重现这一点,但一些用户向我发送了崩溃报告。
堆栈跟踪始终相同(见下文)。该应用程序打开一个模态对话框,用户单击“确定”,声音被加载并崩溃:
[NSSound soundNamed:@"Hero"];
在网络上[1] 有几次提到这个问题,但没有解决方案。请注意,我正在从主线程加载声音,并没有尝试播放它。它立即崩溃。此外,声音文件本身没有损坏(我有一个用户通过电子邮件将其发送给我,它与我安装的那个匹配)。
崩溃日志摘录:
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000009a0d204
VM Regions Near 0x9a0d204:
shared memory 0000000009310000-0000000009511000 [ 2052K] r--/r-- SM=SHM
--> MALLOC_TINY 0000000009a00000-0000000009c00000 [ 2048K] rw-/rwx SM=COW
MALLOC_LARGE 0000000009c00000-000000000bc9c000 [ 32.6M] rw-/rwx SM=PRV
Application Specific Information:
objc[8625]: garbage collection is OFF
Performing @selector(ok:) from sender NSButton 0x236510
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 ??? 0x09a0d204 0 + 161534468
1 com.apple.audio.units.Components 0x7000ed9d AUHAL::AUHAL(ComponentInstanceRecord*, unsigned long, bool) + 775
2 com.apple.audio.units.Components 0x7002feff ComponentEntryPoint<DefaultOutputAU>::Dispatch(ComponentParameters*, DefaultOutputAU*) + 144
3 com.apple.CoreServices.CarbonCore 0x98487949 CallComponent + 223
4 com.apple.CoreServices.CarbonCore 0x98487992 CallComponentDispatch + 29
5 com.apple.CoreServices.CarbonCore 0x984f3b6c CallComponentOpen + 43
6 com.apple.CoreServices.CarbonCore 0x98486608 OpenAComponent + 426
7 com.apple.CoreServices.CarbonCore 0x98486688 OpenComponent + 24
8 com.apple.AppKit 0x9b810cd3 _initializeCA + 1115
9 com.apple.AppKit 0x9b811c23 -[NSSound _postInitialization] + 349
10 com.apple.AppKit 0x9b810609 -[NSSound initWithContentsOfURL:byReference:] + 263
11 com.apple.AppKit 0x9b812767 +[NSSound _searchForSoundNamed:] + 1044
12 com.apple.AppKit 0x9b8122de +[NSSound soundNamed:] + 227
1: http: //lists.apple.com/archives/Cocoa-dev/2007/Oct/msg01159.html