How should I even debug this crash

I’ve been very occasionally and randomly getting this crash when attacking an enemy. The crash log isn’t very helpful since there’s no context as to what code could be causing the crash.

It’s also really difficult to reproduce, seems to happen like every 1 in 1000 times I hit an enemy. I have no clue if it’s even my code, the engine or a plugin causing it.

Does anyone know what this kind of crash is usually caused by?

Assertion failed: IsValidIndex(Index) [File:D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Public\UObject\UObjectArray.h] [Line: 511] IsValidIndex(1090519042)

UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_CoreUObject
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
kernel32
ntdll

well it tells you the line 511, and IsValidIndex

my guess is your trying to reference an object thats been garbage collected

1 Like

Update for anyone else with this problem,
this code was the issue:

FNPCHitInformation newInfo;

newInfo.hitTimer = 2.0f; 
newInfo.player = hitPlayer;

recentlyHitNPCs.Add(newInfo);

It seems like the crash occurs randomly when adding an element to a TArray of custom UStructs.

The solution for me was to remove the UPROPERTY() tag from the TArray in the header file.

//UPROPERTY(BlueprintReadWrite)
TArray<FNPCHitInformation> recentlyHitNPCs;

Removing the tag is not ideal but it works for me so whatever.

As Auran13 said it might be a garbage collection problem, I think It’s probably an unreal engine bug.