EXCEPTION_ACCESS_VIOLATION on a Blueprint Native Event called from a C++ class

Hi! I currently have an issue where I’m getting a crash after a blueprint native event is called from a C++ class and I can’t quite figure out why.

I currently have two blueprint native events called PrePerform and PostPerform. Their C++ implementations are very simple, simply returning true and nothing else. Similarly, their Blueprint implementations are also incredibly simple, as they just call on the C++ implementation. However, occasionally when I try to access these from another C++ class, I get the following crash:

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffffffffffff

UnrealEditor_survivalhorror_patch_0!UActionBase::PostPerform() [C:\Users\MyUser\Documents\Unreal Projects\aisurvivalhorror\Intermediate\Build\Win64\UnrealEditor\Inc\survivalhorror\UHT\ActionBase.gen.cpp:61]
UnrealEditor_survivalhorror_patch_0!UActions::CompleteAction() [C:\Users\MyUser\Documents\Unreal Projects\aisurvivalhorror\Source\survivalhorror\Private\Actions.cpp:122]
UnrealEditor_survivalhorror_patch_0!TBaseUObjectMethodDelegateInstance<0,UActions,void __cdecl(void),FDefaultDelegateUserPolicy>::Execute() [C:\Program Files\Epic Games\UE_5.2\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:535]
UnrealEditor_Engine!FTimerUnifiedDelegate::Execute() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Public\TimerManager.h:48]
UnrealEditor_Engine!FTimerManager::Tick() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\TimerManager.cpp:933]
UnrealEditor_Engine!UWorld::Tick() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1576]
UnrealEditor_UnrealEd!UEditorEngine::Tick() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:1905]
UnrealEditor_UnrealEd!UUnrealEdEngine::Tick() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\UnrealEdEngine.cpp:519]
UnrealEditor!FEngineLoop::Tick() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:5812]
UnrealEditor!GuardedMain() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:188]
UnrealEditor!GuardedMainWrapper() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:107]
UnrealEditor!LaunchWindowsStartup() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:244]
UnrealEditor!WinMain() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:284]
UnrealEditor!__scrt_common_main_seh() [D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
kernel32
ntdll

Occasionnally, the top of the call stack will include these calls in addition to the previously mentioned ones:

ntdll
UnrealEditor_CoreUObject!UClass::FindFunctionByName() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:5858]
UnrealEditor_CoreUObject!UObject::FindFunctionChecked() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1450]

These functions are available on my UActionBase class, and I don’t understand why they’d be throwing this error since I can access their other properties just fine, just not these two functions. Below I’ve included some screenshots which show the PostPerform function, its C++ and Blueprint implementations, and how I’m calling them in my other class. This is exactly the same as the PrePerform function. If anyone knows what’s wrong I’d appreciate the advice, as I’ve never used Blueprint Native Events before today. Thanks!

PostPerform in the .cpp file

Calling PostPerform in another class

I always launch my project via Visual Studio using F5 (Start debugging). That way if a crash happens, VS is attached and will break, allowing me to check everything and find what caused the crash
Try either debugging like that or attaching your debugger while it’s running to be able to intercept crashes

Regardless, if currentAction is null when CompleteAction is called, the game will crash, and I suspect this is what’s happening here. You should probably do a check before running anything on it

1 Like

Actions.zip (2.4 KB)
Made a quick mock up of your code. It seems to work fine if curretAction is initialized



3

OFC _API part in the headers needs to be renamed if you want to test it.

A set Debug point at PostPerform_Implementation fires fine with no errors.

1 Like

Seem to be an issue with the .gen file? currentAction is used multiple times prior to this and at no point gets cleared so it can’t be that. The PostPerform function itself gets used a few times before this crash happens, it seems to happen only after it gets called a few times as it doesn’t throw the exception immediately, I had to wait around a minute in which it activated a few times before crashing.

Just saw that the UActionBase isn’t populated, so it must be that the currentAction is being cleared somewhere I’m not seeing.

Is your currentAction marked as a UPROPERTY? If not then with time it will get garbage collected and become invalid during runtime after a while.

1 Like

If you are suspecting that something is wrong with the intermediates, can always clear your binaries and intermediates folder (or perhaps only the relevant files if you don’t want to recompile your entire project) and compile again

Also what @3dRaven said is very important if you want the object to stay alive

1 Like

No it’s not, I thought that was only required if they were being used in Blueprint?

It needs to be marked to not be GC’d. A uproperty in a way tells unreal that this is important and keep it around :wink:

1 Like

I see, then I’ve got a ton of stuff to mark I suppose. I’ll try that and see if it works, thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.