Access violation in UpdateChangelistMgr

Hello,

I am having troubles with an access violation in UpdateChangelistMgr sometimes right after i add an UObject to an replicated array. I am running out of ideas so any help would be awesome.

The error:

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xfffffdba97390f14

// See if we can re-use the work already done on a previous connection
 1204       		// Rules:
 1205       		//	1. We always compare once per frame (i.e. check LastReplicationFrame == ReplicationFrame)
 1206       		//	2. We check LastCompareIndex > 1 so we can do at least one pass per connection to compare all properties
 1207       		//		This is necessary due to how RemoteRole is manipulated per connection, so we need to give all connections a chance to see if it changed
 1208       		//	3. We ALWAYS compare on bNetInitial to make sure we have a fresh changelist of net initial properties in this case
 1209 ***** 		if (!bForceCompare && GShareShadowState && !RepFlags.bNetInitial && RepState->LastCompareIndex > 1 && InChangelistMgr.LastReplicationFrame

Stacktrace

UE4Editor_Engine!FRepLayout::UpdateChangelistMgr() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\RepLayout.cpp:1210]
UE4Editor_Engine!FObjectReplicator::ReplicateProperties() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\DataReplication.cpp:1614]
UE4Editor_Engine!UActorChannel::ReplicateActor() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\DataChannel.cpp:3173]
UE4Editor_Engine!UNetDriver::ServerReplicateActors_ProcessPrioritizedActors() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\NetDriver.cpp:4471]
UE4Editor_Engine!UNetDriver::ServerReplicateActors() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\NetDriver.cpp:4874]
UE4Editor_Engine!UNetDriver::TickFlush() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\NetDriver.cpp:600]
UE4Editor_Engine!TBaseUObjectMethodDelegateInstance<0,UNetDriver,void __cdecl(float),FDefaultDelegateUserPolicy>::ExecuteIfSafe() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:611]
UE4Editor_Engine!TMulticastDelegate<void __cdecl(float),FDefaultDelegateUserPolicy>::Broadcast() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl:955]
UE4Editor_Engine!UWorld::Tick() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1619]
UE4Editor_Engine!UGameEngine::Tick() [D:\Build\++UE4\Sync\Engine\Source\Runtime\Engine\Private\GameEngine.cpp:1767]

My setup:

Inventory : UActorComponent

UPROPERTY(ReplicatedUsing=OnRep_Items, BlueprintReadOnly, VisibleAnywhere)
	TArray<UItemData*> Items;

virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override {
		Super::GetLifetimeReplicatedProps(OutLifetimeProps);
		DOREPLIFETIME(UInventory, Items);
	}

	virtual bool ReplicateSubobjects(UActorChannel* Channel, FOutBunch* Bunch, FReplicationFlags* RepFlags) override {
		check(Channel && Bunch && RepFlags);
		bool bWroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);
		bWroteSomething |= Channel->ReplicateSubobjectList(Items, *Bunch, *RepFlags);
		return bWroteSomething;
	}

UItemData : UObject

 virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override {
        Super::GetLifetimeReplicatedProps(OutLifetimeProps);

        if (const UBlueprintGeneratedClass* BPClass = Cast<UBlueprintGeneratedClass>(GetClass())) {
            BPClass->GetLifetimeBlueprintReplicationList(OutLifetimeProps);
        }

        DOREPLIFETIME(UItemData, PersistentItemId);
        DOREPLIFETIME(UItemData, Quantity);
        DOREPLIFETIME(UItemData, SpawnedActor);
        DOREPLIFETIME(UItemData, SlotIndex);
        DOREPLIFETIME(UItemData, ItemMetadata);
    }

    virtual bool IsSupportedForNetworking() const override {
        return true;
    }

The call to add items

void SomeMethod(){
      UItemData* item = NewObject<UItemData>(lOwner)->SetData(createdItem.Get()->Id, createdItem.Get()->Quantity, createdItem.Get()->ItemActorId, createdItem.Get()->SlotIndex, itemMetadata);
                inventory->Server_AddItem(item);
}

bool UInventory::Server_AddItem(UItemData* item) {
    Items.Add(item);
    return true;
}

Any idea what might cause the crash?

Hiya,
Did you ever get to the bottom of this. Seeing a very similar callstack.

I’m having similar trouble here. I have an array of UObjects that are setup to replicate. Functionality works fine across most of the logic except when I try and run logic off the back of the OnRep_ function it crashes with a violation on the line that tries to access any property of an element (UObject) of the array.