Crash Report - Engine crash when cloning StaticMeshActor

Applies to 4.9 and 4.8.3 at least. Does not repro on 4.7.3. Sample repro project attached, reproduces on stock 4.9. The editor will crash as soon as Play is clicked.link text

Description : Any Actor that derives from AStaticMeshActor, that also has at least one other component, will crash the engine when cloned using SpawnActor with the template argument set to an existing, valid instance (cloning the actor).

The sample provided does exactly that; it has an actor deriving from AStaticMeshActor, and clones itself in BeginPlay. This is already setup in the level CrashLevel for your convenience.

Here is a callstack of the crash:

    UE4Editor-Core-Win64-Debug.dll!FMallocTBB::Realloc(void * Ptr, unsigned __int64 NewSize, unsigned int Alignment) Line 90	C++
UE4Editor-Core-Win64-Debug.dll!FMemory::Realloc(void * Original, unsigned __int64 Count, unsigned int Alignment) Line 62	C++
UE4Editor-Core-Win64-Debug.dll!TArray<wchar_t,FDefaultAllocator>::AddUninitialized(int Count) Line 1311	C++
UE4Editor-Core-Win64-Debug.dll!FPaths::CollapseRelativeDirectories(FString & InPath) Line 614	C++
UE4Editor-Core-Win64-Debug.dll!FPaths::ConvertRelativePathToFull(const FString & BasePath, const FString & InPath) Line 778	C++
UE4Editor-Core-Win64-Debug.dll!FPaths::ConvertRelativePathToFull(const FString & InPath) Line 762	C++
UE4Editor-Core-Win64-Debug.dll!FWindowsPlatformFile::NormalizeFilename(const wchar_t * Filename) Line 455	C++
UE4Editor-Core-Win64-Debug.dll!FWindowsPlatformFile::GetTimeStamp(const wchar_t * Filename) Line 519	C++
UE4Editor-Core-Win64-Debug.dll!FFileManagerGeneric::GetTimeStamp(const wchar_t * Filename) Line 460	C++
UE4Editor-CoreUObject-Win64-Debug.dll!FPackageName::FindPackageFileWithoutExtension(const FString & InPackageFilename, FString & OutFilename) Line 590	C++
UE4Editor-CoreUObject-Win64-Debug.dll!FPackageName::DoesPackageExist(const FString & LongPackageName, const FGuid * Guid, FString * OutFilename) Line 632	C++
UE4Editor-UnrealEd-Win64-Debug.dll!UCookOnTheFlyServer::Cache(const FName & PackageName) Line 792	C++
UE4Editor-UnrealEd-Win64-Debug.dll!UCookOnTheFlyServer::GetCachedStandardPackageFileFName(const UPackage * Package) Line 751	C++
UE4Editor-UnrealEd-Win64-Debug.dll!UCookOnTheFlyServer::MarkPackageDirtyForCooker(UPackage * Package) Line 2250	C++
UE4Editor-UnrealEd-Win64-Debug.dll!UCookOnTheFlyServer::OnObjectUpdated(UObject * Object) Line 2234	C++
UE4Editor-UnrealEd-Win64-Debug.dll!UCookOnTheFlyServer::OnObjectModified(UObject * ObjectMoving) Line 2216	C++
UE4Editor-UnrealEd-Win64-Debug.dll!TBaseUObjectMethodDelegateInstance<0,UCookOnTheFlyServer,TTypeWrapper<void> __cdecl(UObject * __ptr64)>::Execute(UObject * <Params_0>) Line 682	C++
UE4Editor-UnrealEd-Win64-Debug.dll!TBaseUObjectMethodDelegateInstance<0,UCookOnTheFlyServer,void __cdecl(UObject * __ptr64)>::ExecuteIfSafe(UObject * <Params_0>) Line 772	C++
UE4Editor-CoreUObject-Win64-Debug.dll!TBaseMulticastDelegate<void,UObject * __ptr64>::Broadcast(UObject * <Params_0>) Line 809	C++
UE4Editor-CoreUObject-Win64-Debug.dll!FCoreUObjectDelegates::BroadcastOnObjectModified(UObject * Object) Line 1715	C++
UE4Editor-CoreUObject-Win64-Debug.dll!UObject::Modify(bool bAlwaysMarkDirty) Line 849	C++
UE4Editor-Engine-Win64-Debug.dll!UActorComponent::Modify(bool bAlwaysMarkDirty) Line 447	C++
UE4Editor-Engine-Win64-Debug.dll!AActor::IncrementalRegisterComponents(int NumComponentsToRegister) Line 3614	C++
UE4Editor-Engine-Win64-Debug.dll!AActor::RegisterAllComponents() Line 3566	C++
UE4Editor-Engine-Win64-Debug.dll!AActor::PostSpawnInitialize(const FTransform & UserSpawnTransform, AActor * InOwner, APawn * InInstigator, bool bRemoteOwned, bool bNoFail, bool bDeferConstruction) Line 2508	C++
UE4Editor-Engine-Win64-Debug.dll!UWorld::SpawnActor(UClass * Class, const FTransform * UserTransformPtr, const FActorSpawnParameters & SpawnParameters) Line 430	C++
UE4Editor-Engine-Win64-Debug.dll!UWorld::SpawnActor(UClass * Class, const FVector * Location, const FRotator * Rotation, const FActorSpawnParameters & SpawnParameters) Line 267	C++
UE4Editor-hyperspace-Win64-Debug.dll!AHSPlayerController::HandleCrashTest(AActor * Actor) Line 49	C++

This is quite specific, but my main base actor in my game derives from StaticMeshActor. Any workaround would be fully appreciated, otherwise I am stuck to 4.7 and/or need to rework a large part of my code base and assets. Thanks!

Hey -

I’ve entered a bug report about this crash (UE-20951) for further investigation. I’m not sure if it would work in your case but you could try creating a derived Actor class and adding a static mesh component to it rather than using a derived Static Mesh Actor class.

Cheers

Thanks , I’m trying that, and it involves some serious work since the already existing derived Blueprints are not too happy about seeing their base class change like that. I have to comment code in the editor in order to have it load the blueprints without crashing, so I can recompile them, and they seem ok afterwards. Plus some other weird issues I’m trying to fix.

But I have a question for you for this workaround. We chose to derive from StaticMeshActor in a very early version of the engine (4.1 I believe) because we could not get physics to replicate across network correctly using plain Actors with StaticMeshComponent. Is this a known issue now? Might have been just a temporary bug that got fixed. Thanks!

It looks like you are recursively spawning infinite copies of yourself (SpawnActor will call BeginPlay on the new actor, which will spawn another one, and so on).

No, I put a static variable in the method to prevent that. If you still doubt it, just trigger the spawn on a keypress in the level blueprint, that would ressemble the way I discovered it a bit more.

The crash is not a stack overflow in any case.

Hey -

After a bit more investigation I found that the issue is that the class cannot make the copy of itself. I was able to confirm this by moving the spawn code of your sample project from the BeginPlay() function to a new function that I called through the editor. In the level blueprint I was able to call the new function on BeginPlay or with a key press event. However if I tired to call my new function inside a blueprint based on the CrashActor class I would get the same behavior. The best way to work around this is to have the call to clone the actor come from outside of the actor itself.

Cheers

Ok, let me check that on my side, since my original crash was happening outside of the actor class being spawned, it was spawned by the PlayerController in fact, but I was getting the same exact call stack. I’ll try to repro that in the small project.

Hi , not sure how your version differs than mine, but here’s an update that still crashes, and does not clone from the Actor itself. I added a PlayerController with a blueprint-callable method, that clones the passed-in actor, on ‘F6’ being pressed. That F6 is handled in the level blueprint.

link text

Hey -

I was able to isolate the crash to the “sphere” component added to your actor in the level. The reason I hadn’t crashed was because the blueprint I was using did not have any other components added to it. Removing the Sphere from the CrashActor already in the level prevents the crash from happening as well. You may want to try making sure the full component hierarchy is setup in the code rather than adding components in the editor if you plan on cloning them.

Hey thanks, I already knew that as well, please look up the question above. I can tell you that ALL components I’ve tried have the same effect, added from C++ or blueprints or even instance components. The key here is that the root is a StaticMeshActor. I am able to successfully clone any actor that is not based on StaticMeshActor, with any type of component.

I’ve updated my original bug report with the information gathered.

Great. I’ve been able to migrate to normal Actors as you suggested so I do not depend on the fix.