2011-09-27 92 views
1

偶尔我的Cocoa应用程序在尝试加载系统声音时崩溃。我一直无法自己重现这一点,但一些用户向我发送了崩溃报告。尝试加载系统声音时NSSound崩溃

堆栈跟踪总是相同的(见下文)。该应用程序会打开一个模态对话框,用户点击OK,加载声音和崩溃:

[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

+0

向我们展示更多代码。你在哪里使用这种声音?... – Nekto

+0

显示更多的代码不会帮助,回溯很清楚:'+ [NSSound soundNamed:]'在某些情况下导致崩溃。 – 0xced

回答

0

你mentionned问题的决议(或者说解决方法)在传输changeset 3540应用:不允许自定义声音后来在changeset 5577支持Leopard上的自定义用户声音。

不幸的是,回溯不匹配,您的崩溃日志来自Snow Leopard或Lion,因此这些解决方案可能不适用于您。我建议你向苹果公司提交bug report

+0

谢谢!很高兴听到我不是唯一有这个问题的人。我最终为用户添加了一个选项来禁用声音。 – Mark