我遇到了一个奇怪的崩溃,表现为EXC_BAD_ACCESS总是发生在由FMOD打开的线程的调用堆栈的某个地方调用它的OpenCallback(当FMOD在内存中找不到声音时调用的函数所以需要从磁盘加载它。崩溃发生在许多不同的地方,我似乎无法找到任何原因,因为执行路径基本相同。我注意到的一件事是,在调用堆栈中有两个相同的非递归构造函数的调用。也就是说,调试器(Xcode / LLDB,但我已经尝试使用Xcode / GDB)认为这个构造函数正在调用它自己,但事实并非如此。
我注意到的另一件事是这些调用的偏移量是不同的,即使它们指的是相同的函数。有谁知道可能会发生什么?我很困难,因为我甚至不知道这种问题是什么(因此不能谷歌)。
这是其中一个崩溃的调用堆栈(有些东西因匿名而重命名,但我试图保持命名约定一致)。请注意,CString和PIFilePath构造函数每个都被调用两次,相邻。
* thread #49: tid = 0x6003, 0x009d3220 MyProject`SpinLock::Lock() + 64 at spinlock.h:73, stop reason = EXC_BAD_ACCESS (code=2, address=0xb01f7ffc)
frame #0: 0x009d3220 MyProject`SpinLock::Lock() + 64 at spinlock.h:73
frame #1: 0x0099d8e0 MyProject`tcmalloc::CentralFreeList::RemoveRange(void**, void**, int) + 160 at central_freelist.cc:211
frame #2: 0x009b4989 MyProject`tcmalloc::ThreadCache::FetchFromCentralCache(unsigned long, unsigned long) + 281 at thread_cache.cc:149
frame #3: 0x009d66fc MyProject`tcmalloc::ThreadCache::Allocate(unsigned long, unsigned long) + 332 at thread_cache.h:330
frame #4: 0x009ce123 MyProject`do_malloc + 227 at tcmalloc.cc:960
frame #5: 0x009ce1e5 MyProject`do_malloc_or_cpp_alloc + 85 at tcmalloc.cc:897
frame #6: 0x009d1285 MyProject`MallocBlock::Allocate(unsigned long, int) + 517 at debugallocation.cc:534
frame #7: 0x009ce460 MyProject`DebugAllocate + 48 at debugallocation.cc:968
frame #8: 0x011cc942 MyProject`malloc + 50
frame #9: 0x00a80bbf MyProject`CSystemUtilities::CSAllocate(long, unsigned long, void*) + 47 at CSystemUtilities.cpp:2358
frame #10: 0x96a08d17 CoreFoundation`CFAllocatorAllocate + 343
frame #11: 0x96a0de4b CoreFoundation`__CFStringChangeSizeMultiple + 1179
frame #12: 0x96a219d6 CoreFoundation`CFStringCreateMutableCopy + 454
frame #13: 0x00a9bae2 MyProject`CString::SetCFString(__CFString const*, bool) + 114 at CString.cpp:527
frame #14: 0x00a9bcb0 MyProject`CString::CString(CString const&) + 112 at CString.cpp:189
frame #15: 0x00a9bc1f MyProject`CString::CString(CString const&) + 47 at CString.cpp:190
frame #16: 0x00aa3a9e MyProject`PIFilePath::NormalisePath(CString const&, long, bool, unsigned short) + 2142 at PIFilePath.cpp:2021
frame #17: 0x00aa2dc9 MyProject`PIFilePath::FindPathInList(CString const&, std::vector<CString, std::allocator<CString> > const&) + 89 at PIFilePath.cpp:1716
frame #18: 0x00aa3d26 MyProject`PIFilePath::IsAbsolutePath(CString const&) + 134 at PIFilePath.cpp:465
frame #19: 0x00aa62d1 MyProject`PIFilePath::ApplyMappingsToPath(CString const&, CString const&, bool) + 1041 at PIFilePath.cpp:1323
frame #20: 0x00aa292d MyProject`PIFilePath::TranslatePath(CString const&) const + 4157 at PIFilePath.cpp:1645
frame #21: 0x00aa15ad MyProject`PIFilePath::SetPath(CString const&, PIFilePath::ConvertPathMode) + 253 at PIFilePath.cpp:175
frame #22: 0x00aa1460 MyProject`PIFilePath::PIFilePath(CString const&, PIFilePath::ConvertPathMode) + 96 at PIFilePath.cpp:122
frame #23: 0x00aa13dd MyProject`PIFilePath::PIFilePath(CString const&, PIFilePath::ConvertPathMode) + 61 at PIFilePath.cpp:123
frame #24: 0x00becad8 MyProject`FileAttributes + 88 at pi_files.cpp:3341
frame #25: 0x0090702b MyProject`SystemStuff::CWinFS::Exists(char const*) + 219 at fsWin.cpp:627
frame #26: 0x008e2892 MyProject`SystemStuff::CMultiFS::FindFS(char const*) + 162 at fsMulti.cpp:390
frame #27: 0x008e1466 MyProject`SystemStuff::CMultiFS::Open(SystemStuff::RCPtr<SystemStuff::IBlock>&, char const*, unsigned long) + 134 at fsMulti.cpp:223
frame #28: 0x008db911 MyProject`SystemStuff::CDispatchFS::Open(SystemStuff::RCPtr<SystemStuff::IBlock>&, char const*, unsigned long) + 321 at fsDispatch.cpp:158
frame #29: 0x008cbb89 MyProject`SystemStuff::FS::Open(SystemStuff::RCPtr<SystemStuff::IBlock>&, char const*, unsigned long) + 233 at fs.cpp:135
frame #30: 0x00985611 MyProject`OpenCallback(char const*, int, unsigned int*, void**, void**) + 177 at sndFMODEx.cpp:324
frame #31: 0x029ecf59 libfmodex.dylib`FMOD::DSP::disconnectFrom(FMOD::DSP*) + 25999
frame #32: 0x029ee7cb libfmodex.dylib`FMOD_File_SetDiskBusy + 4861
frame #33: 0x02a0c15b libfmodex.dylib`FMOD::SystemI::createSoundInternal(char const*, unsigned int, unsigned int, unsigned int, FMOD_CREATESOUNDEXINFO*, FMOD::File**, bool, FMOD::SoundI**) + 2413
frame #34: 0x0298b6aa libfmodex.dylib
frame #35: 0x02a11d2c libfmodex.dylib`FMOD::SystemI::createSoundInternal(char const*, unsigned int, unsigned int, unsigned int, FMOD_CREATESOUNDEXINFO*, FMOD::File**, bool, FMOD::SoundI**) + 25918
frame #36: 0x91b6d557 libsystem_c.dylib`_pthread_start + 344
这是我在40%的时间内获得的崩溃,另外60%的时间在NormalisePath
失败(但是上面的callstack是相同的)。