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.