fmod / fmod-for-unreal

FMOD Studio integration with Unreal.
https://fmod.com/resources/documentation-unreal
MIT License
202 stars 84 forks source link

Crash on cooker shutdown #57

Closed gmpreussner closed 3 years ago

gmpreussner commented 3 years ago

Version: 2.01-UE4.26

Problem Description

In _AssetTypeActionsFMODEvent.cpp, FAssetTypeActions_FMODEvent::~FAssetTypeActions_FMODEvent, as part of unregistering callback delegates you are trying to load modules (via Get()). This will not work if the Engine is shutting down.

Callstack

LogWindows: Error: === Critical error: ===
LogWindows: Error:
LogWindows: Error: Fatal error!
LogWindows: Error:
LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION 0x0000000000000000
LogWindows: Error:
LogWindows: Error: [Callstack] 0x0000000000000000 UnknownFunction []
LogWindows: Error: [Callstack] 0x00007ffe98a5fc62 UE4Editor-CoreUObject.dll!UClass::GetDefaultObject() [c:\MyGame\engine\source\runtime\coreuobject\public\uobject\class.h:2886]
LogWindows: Error: [Callstack] 0x00007ffe8c3bf7d1 UE4Editor-BlueprintGraph.dll!FAutocastFunctionMap::Refresh() [c:\MyGame\engine\source\editor\blueprintgraph\private\edgraphschema_k2.cpp:2301]
LogWindows: Error: [Callstack] 0x00007ffe8c393dd4 UE4Editor-BlueprintGraph.dll!TBaseStaticDelegateInstance<void __cdecl(FName,enum EModuleChangeReason),FDefaultDelegateUserPolicy>::ExecuteIfSafe() [c:\MyGame\engine\source\runtime\core\public\delegates\delegateinstancesimpl.h:731]
LogWindows: Error: [Callstack] 0x00007ffe92e8b516 UE4Editor-Core.dll!TMulticastDelegate<void __cdecl(FName,enum EModuleChangeReason),FDefaultDelegateUserPolicy>::Broadcast() [c:\MyGame\engine\source\runtime\core\public\delegates\delegatesignatureimpl.inl:955]
LogWindows: Error: [Callstack] 0x00007ffe92eb200e UE4Editor-Core.dll!FModuleManager::LoadModuleWithFailureReason() [c:\MyGame\engine\source\runtime\core\private\modules\modulemanager.cpp:547]
LogWindows: Error: [Callstack] 0x00007ffe92eb10b9 UE4Editor-Core.dll!FModuleManager::LoadModuleChecked() [c:\MyGame\engine\source\runtime\core\private\modules\modulemanager.cpp:359]
LogWindows: Error: [Callstack] 0x00007ffe659ac52e UE4Editor-FMODStudioEditor.dll!FAssetTypeActions_FMODEvent::~FAssetTypeActions_FMODEvent() [c:\MyGame\neonfuryvr\plugins\fmodstudio\source\fmodstudioeditor\private\assettypeactions_fmodevent.cpp:26]
LogWindows: Error: [Callstack] 0x00007ffe659ac954 UE4Editor-FMODStudioEditor.dll!FAssetTypeActions_FMODEvent::`scalar deleting destructor'() []
LogWindows: Error: [Callstack] 0x00007ffe659d0147 UE4Editor-FMODStudioEditor.dll!FFMODStudioEditorModule::~FFMODStudioEditorModule() []
LogWindows: Error: [Callstack] 0x00007ffe659d118e UE4Editor-FMODStudioEditor.dll!FFMODStudioEditorModule::`scalar deleting destructor'() []
LogWindows: Error: [Callstack] 0x00007ffe92ed2570 UE4Editor-Core.dll!FModuleManager::UnloadModulesAtShutdown() [c:\MyGame\engine\source\runtime\core\private\modules\modulemanager.cpp:731]
LogWindows: Error: [Callstack] 0x00007ff6c35316ea UE4Editor-Cmd.exe!FEngineLoop::Exit() [c:\MyGame\engine\source\runtime\launch\private\launchengineloop.cpp:4216]
LogWindows: Error: [Callstack] 0x00007ff6c3532357 UE4Editor-Cmd.exe!GuardedMain() [c:\MyGame\engine\source\runtime\launch\private\launch.cpp:182]
LogWindows: Error: [Callstack] 0x00007ff6c35323aa UE4Editor-Cmd.exe!GuardedMainWrapper() [c:\MyGame\engine\source\runtime\launch\private\windows\launchwindows.cpp:137]
LogWindows: Error: [Callstack] 0x00007ff6c354649d UE4Editor-Cmd.exe!WinMain() [c:\MyGame\engine\source\runtime\launch\private\windows\launchwindows.cpp:268]
LogWindows: Error: [Callstack] 0x00007ff6c35484c2 UE4Editor-Cmd.exe!__scrt_common_main_seh() [d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
LogWindows: Error: [Callstack] 0x00007fff018c7c24 KERNEL32.DLL!UnknownFunction []
LogWindows: Error: [Callstack] 0x00007fff0386d4d1 ntdll.dll!UnknownFunction []

Recommendation

You should check whether the Engine is shutting down before loading modules, for example:

#include "CoreGlobals.h"
...
FAssetTypeActions_FMODEvent::~FAssetTypeActions_FMODEvent()
{
    if (GIsRunning)
    {
        FEditorDelegates::BeginPIE.Remove(BeginPIEDelegateHandle);
        IFMODStudioEditorModule::Get().BanksReloadedEvent().RemoveAll(this);
        IFMODStudioModule::Get().StopAuditioningInstance();
    }
}
fmod-derek commented 3 years ago

Thanks for reporting this, I haven't been able to reproduce the issue but your problem description and recommendation make perfect sense so I'll add this to our issue tracker to be actioned before the release.