Packaged game crash when loading level (Access violation - code c0000005)

My packaged game works fine,
but it crashes 8 times out of 10 when I load a specific level.

Here is my crash report :

MachineId:800837C847A4628419CFD1AF5676931A
EpicAccountId:8d3b33a34344460bba37b3c32f561d29

Access violation - code c0000005 (first/second chance not available)

UE4Game_Win64_Shipping!TBaseMulticastDelegate::Broadcast()
UE4Game_Win64_Shipping!TGraphTask::ExecuteTask()
UE4Game_Win64_Shipping!FNamedTaskThread::ProcessTasksNamedThread()
UE4Game_Win64_Shipping!FNamedTaskThread::ProcessTasksUntilQuit()
UE4Game_Win64_Shipping!FTaskGraphImplementation::WaitUntilTasksComplete()
UE4Game_Win64_Shipping!FPhysScene::WaitPhysScenes()
UE4Game_Win64_Shipping!FPhysScene::EnsureCollisionTreeIsBuilt()
UE4Game_Win64_Shipping!UWorld::FlushLevelStreaming()
UE4Game_Win64_Shipping!UEngine::LoadMap()
UE4Game_Win64_Shipping!UEngine::Browse()
UE4Game_Win64_Shipping!UEngine::TickWorldTravel()
UE4Game_Win64_Shipping!UGameEngine::Tick()
UE4Game_Win64_Shipping!FEngineLoop::Tick()
UE4Game_Win64_Shipping!GuardedMain()
UE4Game_Win64_Shipping!GuardedMainWrapper()
UE4Game_Win64_Shipping!WinMain()
UE4Game_Win64_Shipping!__scrt_common_main_seh()
kernel32
ntdll

Hello Panelsofsilence,

The main error message that you’re getting alludes to a null pointer issue. This is the one I’m talking about:

Access violation - code c0000005 (first/second chance not available)

Could you check to ensure that anything you’re doing with pointers is checking to ensure that the pointer is valid? Otherwise, to try and narrow down where this is, does this issue happen in Standalone Game as well? If so, you could try attaching the Visual Studio debugger to the process before the crash occurs so that you can see what null is being referenced.

Hi Matthew,

Thanks for your answer, I’m just beggining with programation, and I am learning step by step. So I try to get some infos about “pointers”, but I don’t really understand what they are…

I am almost certain the issue is in my FirstPersonCharacter blueprint.

I am attaching for screenshots of my blueprints. Two are the parts in the Eventgraph where there could be the error, and the third screenshot is the Eventgraph of a fonction that is called in the blueprint :

Could it be related to that?

From looking at what you’ve provided, the only thing that seems like it could possibly cause this would be the “Object” result of “Object in Front of Camera”. It seems that even if the linetrace fails to touch anything, it’ll still try to move forward with the rest of the function and make use of that output, although it is likely null in that scenario. When you try to reference a null pointer, it’ll always cause an access violation.

I would suggest setting up a boolean to store the Return Value of the LineTraceForObjects node and then check that before the Branch you currently have directly after it, only executing the rest of the function if it’s True. Could go a bit further debugging purposes and add a Print String onto the False end of the branch to let you know it failed.

Edit: Or if you would rather avoid creating another variable, have the function also return a boolean and use that.

Hi Matthew,

I edited my blueprint, setting a boolean variable after the function and using it to execute the rest of it. But it didn’t work. I even deleted that part of the blueprint, and the crash is still occuring. So I think it’s not related to that.

My guess is that it would more be related to some kind of data cache :
I have this windows that appears after the crash and that could suggest that way :

I join you also the crash report.

(I cooked the content of the project before building it, through the editor, so I don’t understand the nature of this error message)

alt text

Other weird stuff I have that could cause the crash, when I open the project I have in the Output Log : LogUObjectGlobals:Warning: Failed to find object ‘Class None.’

Apart from that I have no error message while PIE or packaging

This seems like it may be caused by the spaces in your folder names. Unreal Editor doesn’t do that well with spaces in any form which is why we prevent users from including spaces in their project names. Could you try removing the spaces from your folders that have them, such as “VIRTUAL DREAM CENTER” and “BUILD 2”?

Hi Matthew,
Unfortunately removing the spaces in the names of my folders didn’t change anything. It’s still crashing with the same error message.

Thank you for attempting that. Does this project have code at all? If so, in Visual Studio, what configuration are you using when building the project? If you haven’t done it, try packaging for the configuration “Development” or “Shipping” (Not the ones with “Editor” on the end), whichever corresponds with the configuration you’re using when you package. You’ll need to package again after doing this.

Thanks Matthew,
My project only have blueprints scripting (I know nothing yet about C++).
So I just installed Visual Studio 2015 and configured it following the UE documentation. Same with the UnrealVSExtension.
But now I do not succeed in opening my project in Visual Studio… Sorry I’m a newbie here, but I cannot find how to do that in the online documentation. Should I generate a Visual Studio project in UE?

OK! I created a C++ actor and it opened the project in Visual Studio :slight_smile:

Ok (sorry for this step by step comments!), so I did a batch build of the project in Visual Studio, with the shipping config, but… I cannot find it now. Where does it go? Did you mean that by packaging in Visual Studio?
Not knowing what to do next, I just packaged in the UE editor, and it didn’t change anything, still the same crash.

You didn’t need to add code to your project if it didn’t already have code. If you still have a copy of the project that doesn’t have code, I’d suggest going back to using that. If you don’t, create a new project and migrate your content from your old project to it.

Adding code when you don’t plan to do anything with it will only complicate things and cause you more headaches down the line if you’re not sure what to do with it.

Could you take screenshots of your Project Settings > Packaging section for me? Also, what configuration are you packaging for, Development or Shipping? I suggest also trying to run under the PIE setting of “Standalone Window” as this usually has the same behavior as packaged games. See if you get the same issue when using this method.

Hi Matthew,
Yes, I played in Standalone Window and there is still the same crash.
I join you two screenshots of my packaging settings :

(first I was packaging with the “cook only maps” option, but I thought I may cause the crash, so I unchecked the option, but nothing changed)

Since this is only occurring with one of your maps, could you try removing this map temporarily to see if the crash goes away? If so, could you try creating a new map and then migrating the content from the broken map to the new one? It could be something that can be fixed by migration.

Hi Matthew,
It was to difficult, I upgraded my whole project to 4.13, and in 4.13 the crash disappear, hopefully!
Thanks for your help, even if we didn’t figure the reason of this crash.