For some odd reason, UE4 keeps crashing when this is called:
void UEntityAttribute::RegisterPassive(UBasicPassive* passive)
{
attachedPassives.Add(passive);
}
But the thing is, it only crashes on the second time I play on PIE. When I open the engine and play, the engine doesn’t crash when this line is executed. However, if I click stop playing and then click play again the game crashes when this line is reached.
I have no idea why this might be happening, if anyone could shed some light on this I’d be very glad.
This is how I declare [FONT=courier new]attachedPassives
UPROPERTY()
TArray<UBasicPassive*> attachedPassives;
This is how RegisterPassive is called
void UBasicPassive::OnInitialize()
{
Super::OnInitialize();
//Some irrelevant code
targetAttribute->RegisterPassive(this); //targetAttribute can't be null because I do a null check after setting it.
}
And this is how UBasicPassive is created:
UPassiveTaskBase* UTasksComponent::AddPassiveTask(TSubclassOf<UPassiveTaskBase> passive)
{
currentPassives.Add(NewObject<UPassiveTaskBase>(this, passive)); //currentPassives is a UPROPERTY btw
UPassiveTaskBase* passiveInstance = currentPassives.Last(); //I did this because I thought that maybe TArray would change the address of the instance
passiveInstance->target = this;
passiveInstance->OnInitialize();
return passiveInstance;
}
This is the crash log
Access violation - code c0000005 (first/second chance not available)
UE4Editor_Core!rml::internal::reallocAligned() [l:\dev\partner-intel\engine\source hirdparty\inteltbb\inteltbb-4.4u3\src bbmalloc\frontend.cpp:2346]
UE4Editor_Core!scalable_realloc() [l:\dev\partner-intel\engine\source hirdparty\inteltbb\inteltbb-4.4u3\src bbmalloc\frontend.cpp:2900]
UE4Editor_Core!FMallocTBB::Realloc() [d:\build\++ue4\sync\engine\source\runtime\core\private\hal\malloctbb.cpp:123]
UE4Editor_Core!FMemory::Realloc() [d:\build\++ue4\sync\engine\source\runtime\core\public\hal\fmemory.inl:48]
UE4Editor_Hivaneph_7524!TArray<UBasicPassive *,FDefaultAllocator>::ResizeGrow() [c:\program files\epic games\ue_4.20\engine\source\runtime\core\public\containers\array.h:2453]
UE4Editor_Hivaneph_7524!UEntityAttribute::RegisterPassive() [c:\users\dev-projects\ue4\hivaneph\hivaneph\source\hivaneph\entityattribute.cpp:9]
UE4Editor_Hivaneph_7524!UBasicPassive::OnInitialize() [c:\users\dev-projects\ue4\hivaneph\hivaneph\source\hivaneph\passives\basicpassive.cpp:30]
UE4Editor_Hivaneph_7524!UTasksComponent::AddPassiveTask() [c:\users\dev-projects\ue4\hivaneph\hivaneph\source\hivaneph\actions askscomponent.cpp:115]
UE4Editor_Hivaneph_7524!UAbilitySystemComponent::ApplyPassives() [c:\users\dev-projects\ue4\hivaneph\hivaneph\source\hivaneph\abilitysystem\abilitysystemcomponent.cpp:108]
UE4Editor_Hivaneph_7524!UAbilitySystemComponent::UseAbility() [c:\users\dev-projects\ue4\hivaneph\hivaneph\source\hivaneph\abilitysystem\abilitysystemcomponent.cpp:139]
UE4Editor_Hivaneph_7524!UAbilitySystemComponent::UseSelectedAbility() [c:\users\dev-projects\ue4\hivaneph\hivaneph\source\hivaneph\abilitysystem\abilitysystemcomponent.cpp:202]
---> I cut the callstack here because there's no need for you to see all of it <---
Thanks!