UObject Crashes on Duplicate

I’m trying to implement a new UObject type for use in a custom component, and running into issues when duplicating. My component implements GetLifetimeReplicatedProps and marks the UObject with DOREPLIFETIME, which fixed an issue I had with crashes on exiting play mode, but did not address crashes when duplicating.

I’m guessing that I have to implement some additional code to support instancing, but I’m not sure that that is the problem in this case.

Console logs say:

First-chance exception at 0x00007FFD564A53EA (UE4Editor-CoreUObject.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
Unhandled exception at 0x00007FFD564A53EA (UE4Editor-CoreUObject.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

And VS points me to


when exiting.

I’m still quite new to Unreal development, so please let me know if I’m missing information that would be helpful in debugging.

Edit: As a followup question, is UObject even the right way to go? Previously I had stored data in a struct declared in the Component header, which seemed to work well. However, I just assumed that I would need to wrap data that could be instanced and modified in a UObject that is referenced by my component. Is that correct?

More progress: I was able to track down the point of failure to UObjectPropertyBase::FindImportedObject(). The method does successfully find the custom UClass, but my class fails the ObjectProperty->AllowCrossLevel() check. Is it right to assume that that has something to do with loading objects across modules? I can’t find any documentation on what exactly is required to allow an object to be CrossLevel, but my quick test (just commenting out that check) got duplication working without any noticeable side effects. Next question - is it okay to override AllowCrossLevel in a custom plugin class, and how do I do that?

Hey Karl.

So you can reproduce it either by duplicating your actor using the editor viewport right click menu, or by entering and exiting PIE, correct? It looks like this is happening because the static mesh that you’re referencing from the component is a private object in the “transient” package. That is, it’s a synthetic mesh that you created in memory instead of a normal mesh that came from an asset package. I’m guessing you created this object yourself using something like how the CreateStaticMesh() editor function does this.

In any case, you should be able to solve this by making sure the mesh you created is marked as “RF_Public”. References to public assets are allowed when duplicating.