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.

Ambient Sound Callback Crashing on Exit

0 votes

Hello,

I am getting an ambient sound crash on exit, this is on Unreal Engine 4.4.3 with the WWise 4.4 integration.  I would guess this is due to the fact that the object that the callback is trying to operate on is either dereferenced memory or otherwise invalid.  Do you have an intended fix for this issue with 4.5?

This is the code where it crashes:

/*------------------------------------------------------------------------------------
AAkAmbientSound
------------------------------------------------------------------------------------*/
 
/**
 * Static callback for ambient sounds
 */
static void AkAmbientSoundCallback( AkCallbackType in_eType, AkCallbackInfo* in_pCallbackInfo )
{
AAkAmbientSound * pObj = ( (AAkAmbientSound *) in_pCallbackInfo->pCookie );
if( pObj )
{
pObj->Playing( false );
}
}

This is the call stack:  

> ShooterGame-Win64-Shipping.exe!AkAmbientSoundCallback(AkCallbackType in_eType=AK_EndOfEvent, AkCallbackInfo * in_pCallbackInfo=0x000000002351f900) Line 23 C++

  ShooterGame-Win64-Shipping.exe!CAkPlayingMgr::CheckRemovePlayingID(unsigned long in_PlayingID=0, CAkPlayingMgr::PlayingMgrItem * in_pItem=0x0000000020a3a880) Line 166 C++

  ShooterGame-Win64-Shipping.exe!CAkPBI::Term(bool __formal=false) Line 316 C++
  ShooterGame-Win64-Shipping.exe!CAkURenderer::PerformContextNotif() Line 979 C++
  ShooterGame-Win64-Shipping.exe!CAkAudioMgr::Perform() Line 387 C++
  ShooterGame-Win64-Shipping.exe!CAkAudioThread::EventMgrThreadFunc(void * lpParameter=0x0000000000000000) Line 84 C++
  kernel32.dll!BaseThreadInitThunk() Unknown
  ntdll.dll!RtlUserThreadStart() Unknown
 
asked Sep 25, 2014 in General Discussion by Tom W. (180 points)

1 Answer

0 votes
 
Best answer

It seems the AAkAmbientSound has been destroyed before the callback has been called. To safeguard against this, you can change the if( pObj ) to if( pObj && pObj->IsValidLowLevelFast(false) )

This should protect the call to "Playing".
answered Sep 26, 2014 by Benoit S. (Audiokinetic) (16,020 points)
selected Sep 29, 2014 by Tom W.
This worked, thanks!
Hey Benoit,

Actually it looks like there are still scenarios where the AkAmbientSoundCallback will crash.  Sometimes the first two checks in IsValidLowLevelFast() will catch the error and sometimes it falls to this third check which then throws an exception on invalid memory access.

// Crashes trying to dereference this, which is invalid memory.
    if (*(void**)this == NULL)
    {
        UE_LOG(LogUObjectBase, Error, TEXT("Virtual functions table is invalid."));
        return false;
    }
...