Access violation - code c0000005

As I was finishing up clearing some errors I’d been having lately, I did one last build and started getting this crash report.

UE4Editor_Engine!UEngine::AddOnScreenDebugMessage() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\engine\private\unrealengine.cpp:6665]
UE4Editor_PWWW_8126!ADefaultCharacter::ADefaultCharacter() [c:\users\cole\desktop\pwww\project\pwww\source\pwww\private\player\defaultcharacter.cpp:98]
UE4Editor_CoreUObject!UClass::CreateDefaultObject() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\coreuobject\private\uobject\class.cpp:2657]
UE4Editor_CoreUObject!UObjectLoadAllCompiledInDefaultProperties() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:658]
UE4Editor_CoreUObject!ProcessNewlyLoadedUObjects() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\coreuobject\private\uobject\uobjectbase.cpp:752]
UE4Editor_CoreUObject!TBaseStaticDelegateInstance<void __cdecl(void)>::ExecuteIfSafe() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\delegateinstancesimpl_variadics.inl:921]
UE4Editor_Core!TBaseMulticastDelegate<void>::Broadcast() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\public\delegates\delegatesignatureimpl_variadics.inl:809]
UE4Editor_Core!FModuleManager::LoadModuleWithFailureReason() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\core\private\modules\modulemanager.cpp:426]
UE4Editor_Projects!FModuleDescriptor::LoadModulesForPhase() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\projects\private\moduledescriptor.cpp:370]
UE4Editor_Projects!FProjectManager::LoadModulesForProject() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\projects\private\projectmanager.cpp:53]
UE4Editor!FEngineLoop::LoadStartupModules() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\launchengineloop.cpp:1989]
UE4Editor!FEngineLoop::PreInit() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\launchengineloop.cpp:1495]
UE4Editor!GuardedMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\launch.cpp:110]
UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.10\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
kernel32
ntdll

At this point, I have no idea what it could be. The line it mentions in my own code, line 98 in ADefaultCharacter.cpp, doesn’t contain anything that could cause this (it’s a debug print message). I also went through and commented out everything I had been changing earlier, but see no changes. I also can’t seem to get the crash report to change at all, regardless of what I do. Does anyone have any suggestion for how to debug this?

Possibly worth noting- I’ve been having a strange issue recently where my code didn’t seem to build completely in the engine? Even purposefully compiling from the engine, I would still not always see my changes reflected. This began fairly recently.

Also, I have a few instances, including a recently added instance, of creating timer delegates like so:

FTimerDelegate::CreateUObject(this, &Class::Function, value1, .....)

I naively thought that might be the problem, given the references to

CreateDefaultObject

ProcessNewlyLoadedUObjects

TBaseStaticDelegateInstance

etc.

Even after removing it, the problem persists.

That error code generally means that something’s trying to access an object/memory address that isn’t there anymore.

Are you checking your pointers for null before accessing their properties?
e.g.

APlayerController* pc;

// do some stuff

if( pc != nullptr)
{
     pc->SomeFunction();
     //Do some  other stuff
}

Also, if you have any class variables derived from UActor, ensure that you are decorating them correctly with UPROPERTY() e.g.

UPROPERTY()
APlayerCharacter* PlayerCharacter;

Otherwise these objects will get garbage collected and you’ll run into access violations.

I had assumed it must be a null pointer somewhere in my code since I’d been working exclusively there this weekend, aside from redoing some collision channels, and because, admittedly, I haven’t been as strict as I should be with checking my pointers. Even after going through and removing all recent code additions, though, the problem persists. Also, most of the instances where I would have inadvertently created an instance of a null pointer only occur after some amount of gameplay, yet this occurs on starting up the engine.

Unless something changed in the most recent update that would cause my old code to crash (unlikely?), I don’t know what it could be. I was hoping someone might be able to get more from the crash log than I was able to.

Other note I neglected to mention: This occurs on starting the engine, not while running the game.

Ok, I’m at a complete loss. I’ve tried removing the majority of all my project code as well as temporarily relocating the project’s assets to see if one of them was causing the problem. Nothing has changed.

There’s not really anything left to cause problems, yet I’m still seeing this crash.

Well, as per what seems like the norm, I never got any more help with this and eventually found the answer myself.
For anyone else that has this kind of bizarre crash on startup that doesn’t seem to go away, regardless of what you try, it may be an issue with the engine.

What worked for me was cloning my project and replacing the old one. After verifying all my files and making sure everything was working fine, I removed the old, broken project with the cloned version. Everything works fine now.