USphereComponent fails import and then crashes editor on opening actor BP

Hi All

I have a USphereComponent on an Actor, that is used to generate overlap events. It usually works for a while, after placing in a level, then at some point it breaks. On opening the editor I get a failed import message for it. Then when I try and open the actor BP the editor crashes. In debug mode I get this in the stack;

>	UE4Editor-RRDevelop-Win64-DebugGame.dll!ARRStaticFigureNode::OnBeginOverlap(AActor * Other, UPrimitiveComponent * OtherComp, int OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult) Line 241	C++
 	UE4Editor-RRDevelop-Win64-DebugGame.dll!ARRStaticFigureNode::execOnBeginOverlap(FFrame & Stack, void * const Z_Param__Result) Line 32	C++
 	UE4Editor-CoreUObject.dll!UFunction::Invoke(UObject * Obj, FFrame & Stack, void * const Z_Param__Result) Line 4195	C++
 	UE4Editor-CoreUObject.dll!UObject::ProcessEvent(UFunction * Function, void * Parms) Line 1046	C++
 	UE4Editor-Engine.dll!AActor::ProcessEvent(UFunction * Function, void * Parameters) Line 580	C++
 	UE4Editor-Engine.dll!TMulticastScriptDelegate<FWeakObjectPtr>::ProcessMulticastDelegate<UObject>(void * Parameters) Line 459	C++
 	UE4Editor-Engine.dll!FComponentBeginOverlapSignature_DelegateWrapper(const TMulticastScriptDelegate<FWeakObjectPtr> & ComponentBeginOverlapSignature, AActor * OtherActor, UPrimitiveComponent * OtherComp, int OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult) Line 96	C++
 	UE4Editor-Engine.dll!UPrimitiveComponent::BeginComponentOverlap(const FOverlapInfo & OtherOverlap, bool bDoNotifies) Line 1984	C++
 	UE4Editor-Engine.dll!UPrimitiveComponent::UpdateOverlaps(const TArray<FOverlapInfo,FDefaultAllocator> * NewPendingOverlaps, bool bDoNotifies, const TArray<FOverlapInfo,FDefaultAllocator> * OverlapsAtEndLocation) Line 2425	C++
 	UE4Editor-Engine.dll!USceneComponent::UpdateOverlaps(const TArray<FOverlapInfo,FDefaultAllocator> * PendingOverlaps, bool bDoNotifies, const TArray<FOverlapInfo,FDefaultAllocator> * OverlapsAtEndLocation) Line 1917	C++
 	UE4Editor-Engine.dll!UPrimitiveComponent::UpdateOverlaps(const TArray<FOverlapInfo,FDefaultAllocator> * NewPendingOverlaps, bool bDoNotifies, const TArray<FOverlapInfo,FDefaultAllocator> * OverlapsAtEndLocation) Line 2449	C++
 	UE4Editor-Engine.dll!AActor::PostActorConstruction() Line 2679	C++
 	UE4Editor-Engine.dll!AActor::FinishSpawning(const FTransform & UserTransform, bool bIsDefaultTransform) Line 2578	C++
 	UE4Editor-Engine.dll!AActor::PostSpawnInitialize(const FTransform & UserSpawnTransform, AActor * InOwner, APawn * InInstigator, bool bRemoteOwned, bool bNoFail, bool bDeferConstruction) Line 2534	C++
 	UE4Editor-Engine.dll!UWorld::SpawnActor(UClass * Class, const FTransform * UserTransformPtr, const FActorSpawnParameters & SpawnParameters) Line 430	C++
 	UE4Editor-Engine.dll!UWorld::SpawnActor(UClass * Class, const FVector * Location, const FRotator * Rotation, const FActorSpawnParameters & SpawnParameters) Line 267	C++
 	UE4Editor-Kismet.dll!FBlueprintEditor::UpdatePreviewActor(UBlueprint * InBlueprint, bool bInForceFullUpdate) Line 7437	C++
 	UE4Editor-Kismet.dll!FBlueprintEditor::Tick(float DeltaTime) Line 6416	C++
 	UE4Editor-UnrealEd.dll!FTickableEditorObject::TickObjects(float DeltaSeconds) Line 15	C++
 	UE4Editor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1116	C++
 	UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 366	C++
 	UE4Editor.exe!FEngineLoop::Tick() Line 2428	C++
 	UE4Editor.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 142	C++
 	UE4Editor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 189	C++

It hangs on the line;
APawn* PlayerPawn = Controller->GetPawn();

In the OnBeginOverlap event. Obviously the game isnt running, I’m simply opening the BP in the editor.

Thanks!

EDIT:

>    "Assertion failed: InvocationList[
> CurFunctionIndex ] != InDelegate
> [File:C:\Users\Robbie\Documents\GitHub\UnrealEngine\Engine\Source\Runtime\Core\Public\UObject\ScriptDelegat
>     
>     UE4Editor_Core!FDebug::AssertFailed()
> [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\core\private\misc\outputdevice.cpp:354]
>     UE4Editor_RRDevelop!TMulticastScriptDelegate<FWeakObjectPtr>::AddInternal()
> [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\core\public\uobject\scriptdelegates.h:501]
>     UE4Editor_RRDevelop!TBaseDynamicMulticastDelegate<FWeakObjectPtr,void,AActor
> * __ptr64,UPrimitiveComponent * __ptr64,int,bool,FHitResult const & __ptr64>::__Internal_AddDynamic<ANarrator>()
> [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\core\public\delegates\delegatesignatureimpl_variadics.inl:1014]
>     UE4Editor_RRDevelop!ANarrator::BeginPlay()
> [c:\users\robbie\documents\unreal
> projects\rrdevelop\source\rrdevelop\narrator.cpp:139]
>     UE4Editor_Engine!AWorldSettings::NotifyBeginPlay()
> [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\engine\private\worldsettings.cpp:132]
>     UE4Editor_Engine!AGameMode::HandleMatchHasStarted()
> [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\engine\private\gamemode.cpp:605]
>     UE4Editor_Engine!AGameMode::SetMatchState()
> [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\engine\private\gamemode.cpp:721]
>     UE4Editor_Engine!AGameMode::StartMatch()
> [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\engine\private\gamemode.cpp:582]
>     UE4Editor_RRDevelop!ARRDevelopGameMode::StartPlay()
> [c:\users\robbie\documents\unreal
> projects\rrdevelop\source\rrdevelop\rrdevelopgamemode.cpp:39]
>     UE4Editor_Engine!UWorld::BeginPlay()
> [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\engine\private\world.cpp:3050]
>     UE4Editor_Engine!UGameInstance::StartPIEGameInstance()
> [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\engine\private\gameinstance.cpp:273]
>     UE4Editor_UnrealEd!UEditorEngine::CreatePIEGameInstance()
> [c:\users\robbie\documents\github\unrealengine\engine\source\editor\unrealed\private\playlevel.cpp:3020]
>     UE4Editor_UnrealEd!UEditorEngine::PlayInEditor()
> [c:\users\robbie\documents\github\unrealengine\engine\source\editor\unrealed\private\playlevel.cpp:2295]
>     UE4Editor_UnrealEd!UEditorEngine::StartQueuedPlayMapRequest()
> [c:\users\robbie\documents\github\unrealengine\engine\source\editor\unrealed\private\playlevel.cpp:1012]
>     UE4Editor_UnrealEd!UEditorEngine::Tick()
> [c:\users\robbie\documents\github\unrealengine\engine\source\editor\unrealed\private\editorengine.cpp:1244]
>     UE4Editor_UnrealEd!UUnrealEdEngine::Tick()
> [c:\users\robbie\documents\github\unrealengine\engine\source\editor\unrealed\private\unrealedengine.cpp:366]
>     UE4Editor!FEngineLoop::Tick() [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\launch\private\launchengineloop.cpp:2428]
>     UE4Editor!GuardedMain() [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\launch\private\launch.cpp:142]
>     UE4Editor!GuardedMainWrapper() [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
>     UE4Editor!WinMain() [c:\users\robbie\documents\github\unrealengine\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]

I’ve commented out the overlap events within the class in C++, including the AddDynamic in the constructor, and so far thats working. The sphere loads and its not causing any problems. Obviously I can set the overlap events in the BP. but I wonder why its causing probs in C++

Hello robbiecooper,

I’ll be glad to look into this issue for you however I’m unable to know what the issue may be without seeing the code related to this USphereComponent that is causing you to crash. Could you provide the .h / .cpp related? Either direct uploads of the files or pastebins would be helpful.

Thanks Matthew, here you go; Class with bad USphereComponent - Pastebin.com

The overlap bindings and functions are commented out, its been working fine since then (I set up overlap events in BP)

Not quite sure why I didn’t notice this before but from what I understand, AddDynamic is something that is for adding things at runtime instead of in the constructor. Can you try adding them dynamically in something such as OnBeginPlay instead of the constructor?

I suppose its possible I picked that up from a community tutorial. So I moved all of them, in character classes as well as this class, to beginplay. That crashes the editor on begin play, with the call stack that I’ve added to the question

Are you sure thats right? I’ve been using AddDynamic this way for months. If it is right, what would be the correct syntax to use to add events in the constructor?

I was confused about the use of AddDynamic but I understand now. I’ve placed a bug report in for the issue as I was able to reproduce the crash you experienced. For your reference, the bug number is UE-20784. Unfortunately, despite what you’ve already done to workaround the issue, I don’t have anything else to provide.

Have a nice day,

Matthew Clark

Hello robbiecooper,

Can you try using AddDynamic inside of PostInitializeComponents instead of in the constructor? While we’re not exactly sure why this crash is occurring in the constructor as of yet, you should be able to avoid it by using PostInitializeComponents.