User mode data execution error exception

Hi, I’m coming here because I have a problem I can’t solve.
So, I have a base class “Events” and some classes inheriting from it.

class IKOLIA_API UEventsAIDirector : public UObject

	virtual void Trigger(const FTransform& Transform);
	virtual void SetNbEnemies(int Nb);

class IKOLIA_API UEvent_RandomEnemies : public UEventsAIDirector

	virtual void Trigger(const FTransform& Transform) override;
	virtual void SetNbEnemies(int Nb) override;
	int TotalEnemiesToSpawn = 7;

And in another class, I want to be able to store those events in a TArray and select one to Trigger it, I then make a TArray of the parent class to store its children like so :

void UAI_Director::Register_Events(TArray<UEventsAIDirector*>& EventsList)
	UEventsAIDirector* RandomEnemies = NewObject<UEventsAIDirector>(this,UEvent_RandomEnemies::StaticClass(), "Random Enemies Event");

But I am randomly triggering an exception when trying to do this :


The problem is, this happens randomly, its not a consistant error and I don’t have a clue on how to solve it :

Any ideas? Thanks !

1 Like

I encountered this error with a private save game variable in c++. I think the randomness comes from the value being garbage collected.

I found a post on stack overflow with the same error and temporarily disabled my antivirus as it suggested and after I did I started getting a normal access violation error.

Then, I discovered from the following post that I needed to mark my variable as a UPROPERTY() to prevent it from being garbage collected