Description

Class "UInstancedStaticMeshComponent" deliberately leaves null pointers in the "InstanceBodies" array of FBodyInstances. This can be seen in methods such as:

[Engine\Source\Runtime\Engine\Private\InstancedStaticMesh.cpp]
UInstancedStaticMeshComponent::CreateAllInstanceBodies()
UInstancedStaticMeshComponent::SetupNewInstanceData()
UInstancedStaticMeshComponent::UpdateInstanceBodyTransform()

However, method UInstancedStaticMeshComponent::RemoveInstanceInternal() does not take this into account, and the following code crashes the engine by attempting to access such null pointers:

// Re-target instance indices for shifting of array.
for (int32 i = InstanceIndex; i < InstanceBodies.Num(); ++i)
{
InstanceBodies[i]->InstanceBodyIndex = i;
}

[Link Removed]

Vitor Barata 2023-10-19 03:32:14 UTC
Hi [~W014KNNASUF], I've got a JIRA report related to case 00633572.

Steps to Reproduce
  • Open the engine and create a new level
  • Create a blueprint and add a InstancedStaticMeshComponent to it. Set it up with any static mesh.
  • In the ConstructionScript, EventBeginPlay, or any other event you can call in the Editor:
  • Add a 1st instance with the default transform
  • Add a 2nd instance with scale (0,0,0)
  • Remove instance at index 0
  • When running this code, the engine will crash on the removal

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-198455 in the post.

2
Login to Vote

Fixed
ComponentUE - Rendering Architecture
Affects Versions5.3
Target Fix5.4
Fix Commit29084185
Main Commit29084194
CreatedOct 19, 2023
ResolvedOct 25, 2023
UpdatedNov 16, 2023