[Crash]: MovedComponent None not initialized deleteme 0

Dear Friends at Epic,

I spawn and delete a lot of Characters during runtime in my in-game editor.

I spawn these characters with their Blueprint.

During editor mode, I set custom gravity factor to 0 for all characters so they can be moved around to any height above the landscape

When Game mode starts, the gravity factor is restored to 1 and the characters fall from their editor location to the landscape.

#The Context

I run my game only from independent instance, the editor is never loaded.

I am iterating over all Characters to change their gravity during game time using ObjectIterator

Here is my iterator code

for ( TObjectIterator Itr; Itr; ++Itr )
{
	//Evolver is Valid?
	if( ! Itr->IsValidLowLevel()) continue;
    if(Itr->IsPendingKill()) continue;
	//~~~~~~~~~~~~~~~~~~~~~~~
		
	Itr->SERVER_SetGameMode(EnteringGameMode);
}

It is only during this process of iterating over actors and setting their Game Mode to active (does some AI related things and changes their gravity to 1) that the crash occurs.

#When Crash Does Not Occur

The crash only occurs if some characters have been recently spawned / deleted / and new characters spawned,

Then when these characters begin falling when gravity is restored, or even if I take out all my custom gravity code, but the characters are moving around because they are jumping off each other,

when they first begin to move, that is when the crash occurs


#My Set Gravity Function

Here is how I set gravity during starting Game Mode, this code is only related because it causes the characters to start to move.

void AVictoryPlayerCharacterBase::SERVER_SetGravityScale_Implementation(float TheGravityScale)
{
		//Rep
	RepGravityScale = TheGravityScale;
	OnRep_SetGravityScale();
}

void AVictoryPlayerCharacterBase::OnRep_SetGravityScale()
{
	if(!CharacterMovement) return;
	if(!CharacterMovement->IsValidLowLevel()) return;
     if(CharacterMovement->IsPendingKill()) return;
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	
	CharacterMovement->GravityScale = RepGravityScale;
}

#The Crash

I can create as many actors as I want and then delete them and all is well

Then when I go into game mode, all is well.

But if I create a lot of actors, delete a lot of actors, and then create more very quickly,

Sometimes, when a character begins to move, they instantly disappear permanently,

other times I get this crash:

VictorySkelBP_C_22 MovedComponent None not initialized deleteme 0

Address = 0xfd219e5d (filename not found) [in C:\Windows\system32\KERNELBASE.dll]
Address = 0xe18f1a1c (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Core.dll]
Address = 0xe17fc8b2 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Core.dll]
Address = 0xdfa2cb40 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdf9a3a6e (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdf9af5a5 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdf008c3f (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdf0155d4 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdf007a0b (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdf018746 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdef55f67 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdef5ebd6 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdfc3d8f6 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdfc5586f (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xe1729856 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Core.dll]
Address = 0xe172999d (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Core.dll]
Address = 0xe173a93f (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Core.dll]
Address = 0xdfc8b58b (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdfc8fbaf (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdf9464e6 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdf94cbd4 (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0xdf7a818a (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor-Engine.dll]
Address = 0x3fd38edc (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor.exe]
Address = 0x3fd2e8dc (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor.exe]
Address = 0x3fd2e94a (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor.exe]
Address = 0x3fd3a73b (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor.exe]
Address = 0x3fd3b3ef (filename not found) [in C:\Program Files\Rocket\Engine\Binaries\Win64\RocketEditor.exe]
Address = 0x76fd652d (filename not found) [in C:\Windows\system32\kernel32.dll]
Address = 0x7720c521 (filename not found) [in C:\Windows\SYSTEM32\ntdll.dll]
Address = 0x7720c521 (filename not found) [in C:\Windows\SYSTEM32\ntdll.dll]

#What Does This Crash Mean?

What is this crash saying?

How can I protect against it when creating and deleting actors frequently?

This is one of the only crashes I’ve ever gotten which does not point to a place in my source code, who is reporting this crash?

Is it a movementcomponent, is it the engine itself?

The crash is referring to the 23rd instance of the creature I am creating and destroying VictorySkelBP_C_22, who is observing this inconsistency and reporting it?

#IsValidLowLevel() and IsPendingKill()

When I iterate over all actors to activate their gravity when entering game mode,

I do check:

if( ! Itr->IsValidLowLevel()) continue;
 if( Itr->IsPendingKill()) continue;

#Thanks!

Thanks!

Rama

#What Other Checks Can I Do?

What other checks can I do besides IsValidLowLevel() and IsPendingKill() to verify a Character’s integrity while iterating over all objects?

Rama

#Update

It Is Any Kind of Movement

The issue does not seem related to changing the character’s gravity

any kind of movement after spawning/deleting a lot of characters causes the crash

#My Destroy Function

void AVictoryGamePlayerController::VDestroy(UObject * ToDestroy)
{
	if (!ToDestroy) return;
	if (!ToDestroy->IsValidLowLevel()) return;
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	
	//Actor?
	AActor * AnActor = Cast(ToDestroy);
	if (AnActor)
	{
		AnActor->K2_DestroyActor();
		ToDestroy = NULL;
	}
	
	//Object - BeginDestroy
	else
	{
		//Begin Destroy
		ToDestroy->ConditionalBeginDestroy();
		ToDestroy = NULL;
	}
	
	//GC
	GetWorld()->ForceGarbageCollection(true);
	
}

#ForceGarbageCollection

Avoiding forcing garbage collection does not cause any change in behavior

//GC
//GetWorld()->ForceGarbageCollection(true);

#ActorIterator

Using ActorIterator instead of ObjectIterator did not cause any change in behavior

for ( TActorIterator< AEvolver > ActorItr(GetWorld()); ActorItr; ++ActorItr )
{
	//Evolver is Valid?
	if( ! ActorItr->IsValidLowLevel()) 	continue;
	if(ActorItr->IsPendingKill()) 			continue;
	//~~~~~~~~~~~~~~~~~~~~~~~
		
	ActorItr->SERVER_SetGameMode(EnteringGameMode);
}

#Progress Update

I’ve not made any progress with this crash as of yet, any ideas?

:slight_smile:

Rama

Pink Storage is a AI Controller.

#My Spawn Code

void AVictoryPower::JoySpawn_Creatures_Implementation(AEvolver* NewCreature)
{
	if(!NewCreature) return;
	//~~~~~~~~~~~~~
	
	//~~~ Pink Storage ~~~
	APinkStorage * ThePinkStorage = VictoryPC->CreatePinkStorage();
	
	//~~~ Send to Pink Storage ~~~
	if(ThePinkStorage) ThePinkStorage->Possess(NewCreature);
	
	//~~~ No Gravity In Editor Mode ~~~
	NewCreature->SERVER_SetGravityScale(0);
	
	//~~~ Victory Transform Initial ~~~
	NewCreature->SERVER_UpdateVictoryTransformToCurrent();
	
	//Turn to Face
	NewCreature->TurnToFaceAngle = NewCreature->GetActorRotation();
}

//main spawn function
{
	
	//PotentialBP ?
	if (!VictoryPC->SkelBP) return;
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~
	
	SpawnInfo.bNoCollisionFail = true;	//its a global var for general use
	SpawnInfo.Owner = VictoryPC; //the player controller
	
	AVictorySkel* NewCreature = 
		GetWorld()->SpawnActor(VictoryPC->SkelBP, GetActorLocation() ,GetActorRotation() + FRotator(0,90,0), SpawnInfo );

	//~~~ Controller not created ~~~
	if(!NewCreature) return;
	//~~~~~~~~~~~~~~~~~~~~~
	
	JoySpawn_Creatures(NewCreature);
}

#DeferConstruction

Adding bDeferConstruction = false did not cause any change in the crash

SpawnInfo 						= FActorSpawnParameters();
SpawnInfo.bNoCollisionFail 		= true;
SpawnInfo.Owner 				= VictoryPC;
SpawnInfo.bDeferConstruction 	= false; //do NOT defer construction

#bActorInitialized

I added a check thanks to Neil to see if Actor is initialized properly

if it did not get initialized properly during spawn I delete it, an I also run this check when switching to Game Mode / when the actors start moving aorund

//Evolvers
for ( TObjectIterator Itr; Itr; ++Itr )
{
	//Evolver is Valid?
	if( ! Itr->IsValidLowLevel()) 	continue;
	if(Itr->IsPendingKill()) 			continue;
	if(  !  Itr->bActorInitialized)	continue;
	//~~~~~~~~~~~~~~~~~~~~~~~
		
	Itr->SERVER_SetGameMode(EnteringGameMode);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#No Change In Behavior

This crash is still entirely unresolved

#The Crash Nature

Again the crash only occurs if I spawn a bunch of actors, delete them, and then spawn some more

crash does not occur if I just

  • spawn 100s of actors → game mode so creatures start falling/moving
  • spawn 100s then delete all of them → game mode so creatures start falling/moving

error only occurs when I

  • spawn creatures, delete them, spawn some more → game mode so creatures start moving.

#Summary

somehow a conflict is occurring when actors are spawned, deleted, and then more are spawned, during runtime.

#Summary 2

It is only when I spawn, delete them all, and then spawn some more that this crash occurs

so there’s some kind of overlap occurring within the engine between the recently deleted actors and the newly spawned actors,

What happens if you switch to using the Destroy member function instead of the Kismet K2_Destroy member function?

I will go try that now :slight_smile:

#Destroy instead of K2_DestroyActor

Switching from Actor->Destroy() to the Kismet2 version did not cause any improvement in the crash behavior

//AnActor->K2_DestroyActor();
AnActor->Destroy();

#Video

I have a video of how the creatures start with no gravity at around 9:50

and then fall to ground when game mode starts

when game mode starts and they start moving is when this crash occurs, every time, reliably.

Again, only IF I had deleted a whole bunch and the spawned some more and then deleted and then spawned some more

Video Link to Youtube

#Only Characters

This crash only happens with Characters, who have a movement component which seems to be part of the crash

Rama

Hi Rama,

If possible, would you be able to make a fresh project and solely re-create the conditions under which this crash occurs? If so, we would be interested in accessing the project for testing.

Cheers

How are you spawning the actors? I’ve seen that crash with actors that weren’t fully initialized…

Here’s my spawn code!

What do you mean by a spawned creature that is not fully initialized?

What do you constitute as fully initialized?

:slight_smile:

Pink Storage is a AI Controller.

#My Spawn Code

void AVictoryPower::JoySpawn_Creatures_Implementation(AEvolver* NewCreature)
{
	if(!NewCreature) return;
	//~~~~~~~~~~~~~
	
	//~~~ Pink Storage ~~~
	APinkStorage * ThePinkStorage = VictoryPC->CreatePinkStorage();
	
	//~~~ Send to Pink Storage ~~~
	if(ThePinkStorage) ThePinkStorage->Possess(NewCreature);
	
	//~~~ No Gravity In Editor Mode ~~~
	NewCreature->SERVER_SetGravityScale(0);
	
	//~~~ Victory Transform Initial ~~~
	NewCreature->SERVER_UpdateVictoryTransformToCurrent();
	
	//Turn to Face
	NewCreature->TurnToFaceAngle = NewCreature->GetActorRotation();
}

//main spawn function
{
	
	//PotentialBP ?
	if (!VictoryPC->SkelBP) return;
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~
	
	SpawnInfo.bNoCollisionFail = true;	//its a global var for general use
	SpawnInfo.Owner = VictoryPC; //the player controller
	
	AVictorySkel* NewCreature = 
		GetWorld()->SpawnActor(VictoryPC->SkelBP, GetActorLocation() ,GetActorRotation() + FRotator(0,90,0), SpawnInfo );

	//~~~ Controller not created ~~~
	if(!NewCreature) return;
	//~~~~~~~~~~~~~~~~~~~~~
	
	JoySpawn_Creatures(NewCreature);
}

Can you add the following code before calling GetWorld()->SpawnActor()?

SpawnInfo.bDeferConstruction = false;

I can’t see what else you might set in your FActorSpawnParameters object from that code.

Also, where are you spawning the actors? I’m assuming you’re doing it inside the Tick() function of one of your actors?

The only thing I can think that you could check (and are not already checking) is the bActorInitialized property on your AActor objects.