Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

CAkBankMgr random crash while loading soundbank

+1 vote
I upgraded to Wwise 2017.2.1 build 6524 and now it randomly crashes 1 in 20 times or so while loading sound banks. Happens on Windows 10 and Linux.

Seems to happen more often when a debugger is attached. In fact I think it happens every single time on Linux, but only when gdb is attached

Unhandled exception thrown: read access violation.
pDevice was nullptr.

>    deceiver.exe!CAkBankMgr::ReadBus(const AkBank::AKBKSubHircSection & in_rSection, CAkUsageSlot * in_pUsageSlot) Line 2700    C++    Symbols loaded.
     deceiver.exe!CAkBankMgr::ProcessHircChunk(CAkUsageSlot * in_pUsageSlot, unsigned long in_dwBankID) Line 2109    C++    Symbols loaded.
     deceiver.exe!CAkBankMgr::LoadBank(CAkBankMgr::AkBankQueueItem in_Item, CAkUsageSlot * & out_pUsageSlot, CAkBankMgr::AkLoadBankDataMode in_eLoadMode, bool in_bIsFromPrepareBank, bool in_bDecode) Line 853    C++    Symbols loaded.
     [Inline Frame] deceiver.exe!CAkBankMgr::LoadBankPre(CAkBankMgr::AkBankQueueItem &) Line 930    C++    Symbols loaded.
     deceiver.exe!CAkBankMgr::ExecuteCommand(CAkBankMgr::AkBankQueueItem & in_Item) Line 476    C++    Symbols loaded.
     [Inline Frame] deceiver.exe!CAkThreadedBankMgr::ExecuteCommand() Line 192    C++    Symbols loaded.
     deceiver.exe!CAkThreadedBankMgr::BankThreadFunc(void * lpParameter) Line 134    C++    Symbols loaded.

Here's the stack trace on Linux:

#0 CAkBankMgr::ReadBus (this=this@entry=0x7fffc411e4d0, in_rSection=..., in_pUsageSlot=in_pUsageSlot@entry=0x7fffc4160b18) at ../Common/AkBankMgr.cpp:2700
#1 0x000000000092ef22 in CAkBankMgr::ProcessHircChunk (this=this@entry=0x7fffc411e4d0, in_pUsageSlot=0x7fffc4160b18, in_dwBankID=in_dwBankID@entry=1835346959) at ../Common/AkBankMgr.cpp:2109
#2 0x0000000000933352 in CAkBankMgr::LoadBank (this=this@entry=0x7fffc411e4d0, in_Item=..., out_pUsageSlot=@0x7fffedaaac60: 0x7fffc4160b18, in_eLoadMode=in_eLoadMode@entry=CAkBankMgr::AkLoadBankDataMode_OneBlock, in_bIsFromPrepareBank=in_bIsFromPrepareBank@entry=false, in_bDecode=in_bDecode@entry=false) at ../Common/AkBankMgr.cpp:853
#3 0x0000000000933510 in CAkBankMgr::LoadBankPre (this=0x7fffc411e4d0, in_rItem=...) at ../Common/AkBankMgr.cpp:930
#4 0x00000000009ec1c3 in CAkThreadedBankMgr::ExecuteCommand (this=this@entry=0x7fffc411e4d0) at ../Common/AkThreadedBankMgr.cpp:192
#5 0x00000000009ec248 in CAkThreadedBankMgr::BankThreadFunc (lpParameter=0x7fffc411e4d0) at ../Common/AkThreadedBankMgr.cpp:134
#6 0x00007ffff74807fc in start_thread (arg=0x7fffedaab700) at pthread_create.c:465
#7 0x00007ffff5f59b5f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

I have a Windows minidump if needed.
asked Feb 28, 2018 in General Discussion by Evan T. (290 points)

2 Answers

0 votes
I think I solved this by moving the init stuff to another thread.
answered Mar 2, 2018 by Evan T. (290 points)
0 votes
There's a potential race condition here. The CAkOutputMgr isn't initialized until CAkAudioThread::EventMgrThreadFunc starts, so if that thread gets held up and you load a bank very shortly after AK::SoundEngine::Init, you can crash.

You can wait for a Global or Device Status callback to be sure the audio thread is ready, but I think that might still hang if there is no valid audio device, or if it's suspended. I think the real fix will have to come from AK.
answered Mar 26, 2018 by Aaron A. (150 points)