Havok Crash during FBodyInstance::UpdatePhysicsFilterData

The crash happens when the editor is loading the default map. No PIE is required. This is strictly caused by the editor loading the map. The issue is in BodyInstance.cpp and appears to be caused by various functions being able to query a mesh that was being async built. On completion of the mesh compilation, the BodyInstance will receive a new ActorHandle which can invalidate other ActorHandles that were captured by lambda’s closures.

The simple fix appears to be use the GetPhysicsActor() function to ensure that the used ActorHandle is always up to date. The attached file “Issue Timing” shows when the ActorHandle “Actor” parameter becomes dangling.

[Attachment Removed]

Steps to Reproduce

This is about a race condition between a StaticMeshComponent’s BodyInstance initialization and the completion of the StaticMesh’s compilation via FStaticMeshCompilingManager.

The issue seems confined to code executed in the FBodyInstance::UpdatePhysicsFilterData() found in “UE5\Engine\Source\Runtime\Engine\Private\PhysicsEngine\BodyInstance.cpp”.

The FStaticMeshCompilingManager’s async compilation must finish during the FPhysicsCommand::ExecuteWrite command of the UpdatePhysicsFilterData function.

When the timing is correct, the BodyInstance’s ActorHandle will get updated and point to a new FSingleParticlePhysicsProxy.

At the same time, the lambda function’s parameter ‘Actor’ will become a dangling pointer. This will cause the line FPhysicsInterface::WakeUp_AssumesLocked(Actor) to behave incorrectly.

[Attachment Removed]

Hi Thierry,

I’m afraid we do not support Havok since it is an external product to ours (our product is Chaos) and we do not have the full insight as to what they are doing in terms of integration. If you reach out to them, I’m sure they would be happy to help.

All the best

Geoff Stacey

Developer Relations

EPIC Games

[Attachment Removed]

Hi Thierry,

They are not, but this is a timing issue - and that is something which Havok may be in control of and hence would be more sensible to investigate on their side since they have better visibility.

Best

Geoff

[Attachment Removed]

Hello,

I was not aware that runtime mesh compilation was part of the Havok product nor that the BodyInstance code that I mentioned was Havok specific. I’ll get in touch with them for further support.

Thank you!

[Attachment Removed]