[CRASH] CopyInstanceVertexColorsIfCompatible in Replace Actor

Getting a crash when trying to replace an actor in the editor. Crash happens in UStaticMeshComponent::CopyInstanceVertexColorsIfCompatible after being called from UEditorEngine::ReplaceActors

FStaticMeshLODResources& SourceLODModel = SourceComponent->GetStaticMesh()->RenderData->LODResources[CurrentLOD];
			FStaticMeshComponentLODInfo& SourceLODInfo = SourceComponent->LODData[CurrentLOD]; // CRASHES HERE

			FStaticMeshLODResources& TargetLODModel = GetStaticMesh()->RenderData->LODResources[CurrentLOD];
			FStaticMeshComponentLODInfo& TargetLODInfo = LODData[CurrentLOD];

			if ( SourceLODInfo.OverrideVertexColors != NULL )
			{
				// Copy vertex colors from source to target.
				FColorVertexBuffer* SourceColorBuffer = SourceLODInfo.OverrideVertexColors;

				TArray< FColor > CopiedColors;
				for ( uint32 ColorVertexIndex = 0; ColorVertexIndex < SourceColorBuffer->GetNumVertices(); ColorVertexIndex++ )
				{
					CopiedColors.Add( SourceColorBuffer->VertexColor( ColorVertexIndex ) );
				}

				FColorVertexBuffer* TargetColorBuffer = &TargetLODModel.ColorVertexBuffer;

				if ( TargetLODInfo.OverrideVertexColors != NULL )
				{
					TargetLODInfo.BeginReleaseOverrideVertexColors();
					FlushRenderingCommands();
				}
				else
				{
					TargetLODInfo.OverrideVertexColors = new FColorVertexBuffer;
					TargetLODInfo.OverrideVertexColors->InitFromColorArray( CopiedColors );
				}
				BeginInitResource( TargetLODInfo.OverrideVertexColors );
			}

It appears to be an index out of range error. The test case here is replacing a StaticMeshActor with a blueprint containing the same static mesh + some other stuff, not sure if that’s related but its a consistent crash.

Hey -

Can you provide the callstack from the crash for additional information? If the crash is easily reproducible, please also include exact repro steps to help me reproduce the crash on my end.

Hey -

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will follow up.

Cheers

Sorry , I didn’t get alerted to your initial response for some reason. Unfortunately I can’t get a callstack anymore, I ended up editing the source code myself to work around this issue. Not an actual fix, just commenting out the call to UStaticMeshComponent::CopyInstanceVertexColorsIfCompatible since it was crashing in there and I didn’t need it.

It appeared to be crashing on the second line here, line1061 (UE 4.15):

		FStaticMeshLODResources& SourceLODModel = SourceComponent->GetStaticMesh()->RenderData->LODResources[CurrentLOD];
		FStaticMeshComponentLODInfo& SourceLODInfo = SourceComponent->LODData[CurrentLOD];

with an index out of range error.