Got an access violation while debugging.
After checking the callstack, best I can tell everything is fine from my end.
Meaning it successfully created the object. The break occurred in FindId().
I honestly don’t know how this part of the engine code works, nor how I could fix it on my end.
Ive posted the call stack below, with information from when NewObject, HashObject, and FindId is called, relating to the object my code was spawning.
How can I avoid running into this potential crash in the future?
Exception thrown at 0x000007FEDFF3D606 (UE4Editor-CoreUObject.dll) in UE4Editor.exe:
0xC0000005: Access violation reading location 0xFFFFFFFAD8613000.
UE4Editor-CoreUObject.dll!TSet<UObjectBase * __ptr64,DefaultKeyFuncs<UObjectBase * __ptr64,0>,FDefaultSetAllocator>::FindId(UObjectBase * Key) Line 630
Key = 0x00000000346d4f00 (Name=0x000000002b84ce18 "OC_WP_BasicRailProjectile_C"_78)
Elements - (10 valid, 34 total)
Indexes (0 to 6) and (24 to 26) = OC_WP_BasicRailProjectile_C
the rest of the indexes = Invalid
ElementId = {Index=-1548787584 }
UE4Editor-CoreUObject.dll!TSet<UObjectBase * __ptr64,DefaultKeyFuncs<UObjectBase * __ptr64,0>,FDefaultSetAllocator>::Emplace<UObjectBase * __ptr64 const & __ptr64>(UObjectBase * const & Args, bool * bIsAlreadyInSetPtr) Line 502
[Inline Frame] UE4Editor-CoreUObject.dll!TSet<UObjectBase *,DefaultKeyFuncs<UObjectBase *,0>,FDefaultSetAllocator>::Add(UObjectBase * const &) Line 475
[Inline Frame] UE4Editor-CoreUObject.dll!AddToClassMap(FUObjectHashTables & Object, UObjectBase *) Line 555
UE4Editor-CoreUObject.dll!HashObject(UObjectBase * Object) Line 907
Object = 0x00000000346d4f00 (Name=0x000000002b84ce18 "OC_WP_BasicRailProjectile_C"_78)
UE4Editor-CoreUObject.dll!UObjectBase::AddObject(FName InName, EInternalObjectFlags InSetInternalFlags) Line 220
UE4Editor-CoreUObject.dll!UObjectBase::UObjectBase(UClass * InClass, EObjectFlags InFlags, EInternalObjectFlags InInternalFlags, UObject * InOuter, FName InName) Line 96
UE4Editor-CoreUObject.dll!StaticAllocateObject(UClass * InClass, UObject * InOuter, FName InName, EObjectFlags InFlags, EInternalObjectFlags InternalSetFlags, bool bCanRecycleSubobjects, bool * bOutRecycledSubobject) Line 2398
UE4Editor-CoreUObject.dll!StaticConstructObject_Internal(UClass * InClass, UObject * InOuter, FName InName, EObjectFlags InFlags, EInternalObjectFlags InternalSetFlags, UObject * InTemplate, bool bCopyTransientsFromClassDefaults, FObjectInstancingGraph * InInstanceGraph, bool bAssumeTemplateIsArchetype) Line 3121
UE4Editor-Engine.dll!NewObject<AActor>(UObject * Outer, UClass * Class, FName Name, EObjectFlags Flags, UObject * Template, bool bCopyTransientsFromClassDefaults, FObjectInstancingGraph * InInstanceGraph) Line 1204
StaticConstructObject_Internal
Class = 0x0000000042c14100 (Name=0x000000002b84ce18 "OC_WP_BasicRailProjectile_C")
Outer = 0x0000000044462b00 (Name=0x0000000002a96e18 "PersistentLevel")
Name = 0x0000000002a964d0 "None"
Flags = RF_Transactional (8)
InternalSetFlags = EInternalObjectFlags::None
Template = 0x0000000042be6b00 (Name=0x000000003456c690 "Default__OC_WP_BasicRailProjectile_C")
bCopyTransientsFromClassDefaults = false
InInstanceGraph = NULL
UE4Editor-Engine.dll!UWorld::SpawnActor(UClass * Class, const FTransform * UserTransformPtr, const FActorSpawnParameters & SpawnParameters) Line 425
UE4Editor-Engine.dll!UWorld::SpawnActor(UClass * Class, const FVector * Location, const FRotator * Rotation, const FActorSpawnParameters & SpawnParameters) Line 291
[Inline Frame] UE4Editor-OrtCloud.dll!UWorld::SpawnActor(UClass * SpawnParameters, const FVector &) Line 2728
UE4Editor-OrtCloud.dll!AOrtCloudShipComponent::DoFire(int InIndex, AActor * CurrentTarget) Line 4816
UE4Editor-OrtCloud.dll!AOrtCloudShipComponent::DoBurst(int InIndex) Line 4742
UE4Editor-OrtCloud.dll!AOrtCloudShipComponent::StartBursting(int InIndex) Line 4631
UE4Editor-CoreUObject.dll!UFunction::Invoke(UObject * Obj, FFrame & Stack, void * const Z_Param__Result) Line 4461
UE4Editor-CoreUObject.dll!UObject::ProcessEvent(UFunction * Function, void * Parms) Line 1334
UE4Editor-Engine.dll!AActor::ProcessEvent(UFunction * Function, void * Parameters) Line 699
UE4Editor-OrtCloud.dll!TBaseUFunctionDelegateInstance<AOrtCloudShipComponent,TTypeWrapper<void> __cdecl(void),int>::Execute() Line 137
[Inline Frame] UE4Editor-Engine.dll!TBaseDelegate<TTypeWrapper<void> >::Execute() Line 537
UE4Editor-Engine.dll!FTimerUnifiedDelegate::Execute() Line 46
UE4Editor-Engine.dll!FTimerManager::Tick(float DeltaTime) Line 574
UE4Editor-Engine.dll!UWorld::Tick(ELevelTick TickType, float DeltaSeconds) Line 1441
UE4Editor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1650
UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 402
UE4Editor.exe!FEngineLoop::Tick() Line 3215
[Inline Frame] UE4Editor.exe!EngineTick() Line 62
UE4Editor.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 166
UE4Editor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 199