Hey,
After upgrading to 5.5.4 some people are consistently seeing a crash in one of three locations (see attached file for callstacks).
- BuildSignedDistanceFieldBuildSectionData : LN 177
- FStaticMeshSceneProxyDesc::GetMaterial : LN 158
- UStaticMeshComponent::GetMaterial : LN 2886
After catching it in the debugger, all of the crashes had one thing in common, they were all trying to access a UMaterialInterface despite the underlying object actually being a UObjectRedirector type shown by the debugger.
This means that, somewhere, a UObject has been unconditionally cast to UMaterialInterface even though it is a UObjectRedirector. This then essentially causes a memory stomp because we try to call functions that are associated with the UMaterialInterface type on what is actually a UObjectRedirector type meaning we could end up anywhere in memory.
Questions
- Can you shed any light on whether this is expected behaviour or not?
- It seems totally bizarre that the redirectors are not being handled either before they are in use by the static mesh object or the objects should be handling the redirect themselves.
- Is this a known issue and what is your suggested work around for this?
- How and where is it that the unconditional cast to UMaterialInterface is happening? This feels like a bug with that code.
Workaround(s)
So, based on this discovery, I made the following change in all locations listed above to properly handle the redirect and this stops the crash from happening, I assume that fixing up redirectors works as well but that feels like a temporary solution, can you please advise us on a permanent fix here please?
`// <#CCP_MOD>
//
// Traverse redirectors until we find the destination object
//
{
UObject* TempObj = OutMaterial;
while (UObjectRedirector* Redirector = Cast(TempObj))
{
TempObj = Redirector->DestinationObject;
}
OutMaterial = Cast(TempObj);
}
// </#CCP_MOD>`