Help with a Shipping build only crash in GameStateBase::HandleBeginPlay()

I’ve been running into a weird crash on my new project in UE5.4.2, the project is primarily C++ with minimal blueprint work. The game runs perfectly fine playing in editor, playing the shipping build crashes with this exception & callstack:

Exception thrown at 0x00007FF6621C384F in BinarySiege-Win64-Shipping.exe: 0xC0000005: Access violation reading location 0x0000000000000020.

 	Playground-Win64-Shipping.exe!UObject::execCallMathFunction(class UObject *,struct FFrame &,void * const)	C++
 	Playground-Win64-Shipping.exe!ProcessLocalScriptFunction(class UObject *,struct FFrame &,void * const)	C++
 	Playground-Win64-Shipping.exe!ProcessScriptFunction<void (*)(class UObject *,struct FFrame &,void *)>(class UObject *,class UFunction *,struct FFrame &,void * const,void (*)(class UObject *,struct FFrame &,void *))	C++
 	Playground-Win64-Shipping.exe!UObject::execLocalFinalFunction(class UObject *,struct FFrame &,void * const)	C++
 	Playground-Win64-Shipping.exe!ProcessLocalScriptFunction(class UObject *,struct FFrame &,void * const)	C++
 	Playground-Win64-Shipping.exe!UObject::ProcessInternal(class UObject *,struct FFrame &,void * const)	C++
 	Playground-Win64-Shipping.exe!UFunction::Invoke(class UObject *,struct FFrame &,void * const)	C++
 	Playground-Win64-Shipping.exe!UObject::ProcessEvent(class UFunction *,void *)	C++
 	Playground-Win64-Shipping.exe!AActor::ProcessEvent(class UFunction *,void *)	C++
 	Playground-Win64-Shipping.exe!AActor::BeginPlay(void)	C++
 	Playground-Win64-Shipping.exe!AActor::DispatchBeginPlay(bool)	C++
 	Playground-Win64-Shipping.exe!AWorldSettings::NotifyBeginPlay(void)	C++
 	Playground-Win64-Shipping.exe!AGameStateBase::HandleBeginPlay(void)	C++
 	Playground-Win64-Shipping.exe!UWorld::BeginPlay(void)	C++
 	Playground-Win64-Shipping.exe!UEngine::LoadMap(struct FWorldContext &,struct FURL,class UPendingNetGame *,class FString &)	C++
 	Playground-Win64-Shipping.exe!UEngine::Browse(struct FWorldContext &,struct FURL,class FString &)	C++
 	Playground-Win64-Shipping.exe!UGameInstance::StartGameInstance(void)	C++
 	Playground-Win64-Shipping.exe!FEngineLoop::Init(void)	C++
 	Playground-Win64-Shipping.exe!GuardedMain(wchar_t const *)	C++
 	Playground-Win64-Shipping.exe!GuardedMainWrapper(wchar_t const *)	C++
 	Playground-Win64-Shipping.exe!LaunchWindowsStartup(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int,wchar_t const *)	C++
 	Playground-Win64-Shipping.exe!WinMain()	C++
>	[Inline Frame] Playground-Win64-Shipping.exe!invoke_main() Line 102	C++
 	Playground-Win64-Shipping.exe!__scrt_common_main_seh() Line 288	C++

I’m struggling to work out where to look next for a cause or solution. Any suggestions/comments welcome.

Some context & testing I’ve done:

  • My game uses a custom GameStateBase derived GameState, the crash is the same whether I use this or revert to the standard GameStateBase.
  • The world has no actors on startup aside from the defaults Unreal creates and a camera, everything gets spawned by the GameState, which never actually runs.
  • The crash is in some kind of Local Script (Blueprint?) Math functions - I do not have any maths I’m aware of happening in blueprints
  • Loading into a different Map works fine, then transitioning into this map crashes immediately.
  • Creating an empty dummy world and assigning my GameMode (whigh has custom PlayerController and HUD C++ classes) causes the same crash.
  • Removing the BeginPlay->SetScalabilityQualityToEpic node I have on the GameMode fixes the crash in my dummy world, and changes the crash in my real world to occur in
 	Playground-Win64-Shipping.exe!APlayerCameraManager::UpdateViewTarget(struct FTViewTarget &,float)	C++
 	Playground-Win64-Shipping.exe!APlayerCameraManager::DoUpdateCamera(float)	C++
 	Playground-Win64-Shipping.exe!APlayerCameraManager::UpdateCamera(float)	C++
 	Playground-Win64-Shipping.exe!UWorld::Tick(enum ELevelTick,float)	C++
 	Playground-Win64-Shipping.exe!UGameEngine::Tick(float,bool)	C++
 	Playground-Win64-Shipping.exe!FEngineLoop::Tick(void)	C++
 	Playground-Win64-Shipping.exe!GuardedMain(wchar_t const *)	C++
 	Playground-Win64-Shipping.exe!GuardedMainWrapper(wchar_t const *)	C++
 	Playground-Win64-Shipping.exe!LaunchWindowsStartup(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int,wchar_t const *)	C++
 	Playground-Win64-Shipping.exe!WinMain()	C++
>	[Inline Frame] Playground-Win64-Shipping.exe!invoke_main() Line 102	C++

Removing the Camera’s “Auto Activate For Player” setting fixes this crash and the game now loads, although with no camra so it’s a bit broken!

These two different crashes in engine code make me thing something is rather screwed up in my project, but I have no idea how to tell where. I also have no idea why this would be different in Shipping - PlayInEditor always works absolutely fine.

I am having the same problem, in UE 5.3 shipping build, a crash in the
DebugGame.exe: 0xC0000005: Access violation reading location 0x0000000000000020.
at the DebugGame.exe!UObject::execCallMathFunction(class UObject *,struct FFrame &,void * const) C++ - Function.

In Short:
(3) - Fixed the issue, found the crash reason, inside a function called ‘OnLevelLoadFinishedBP’. It would be nice to also have UE debugging symbols somehow attached to a debug build.

Long:
I am currently debugging it. The problem is that when I attach the debugger I can’t see the symbols of what happens inside the engine, since the ‘.pdb’ in shipping only includes the game’s info. I’m trying to somehow trick the system so that I have better info on the problem.

What I have tried:

  1. Moving ‘UnrealEditor-CoreUObject.pdb’ from the engine build to the location of the game and renaming it to ‘Game-Win64-DebugGame.pdb’ in order to better debug exactly around the crash, but it didn’t work, the PDB is not recognized
  2. Place prints around that function to see that it crashes inside it, however it seems that the blueprint side of things gets properly executed, so the problem seems to be in UE
  3. I’ve managed to run the game with the command Game-Win64-DebugGame.exe -WaitForAttach and that allows me to attach the debugger (VS - Attach To Process). Don’t be scared by the fact that the param -WaitForAttach does not start anything, that is because it only pre-starts it in the system, and it is visible in the VS process list (and in the task manager). There is a custom function that gets called on an actor before the crash called ‘OnLevelLoadFinishedBP’, and inside that function another function is called on a component object that caused the crash at runtime.

Note: a debug package option that can somehow build the DLLs without packing them in the exe, or generating the full PDB for the executable (including for engine functions) would be a lot better when debugging weird problems like this. Is there any issue or something along those lines that I am not aware of?