4.18 crash after destroying DestructibleComponent

Hi Ori,

I tried a very similar approach first, but there are more complications. At the time OnDestroyPhysicsState runs, the async scene has started, but not completed processing yet, so when it completes, it will immediately clear the ignore actor list in ProcessPhysScene. Then later the deferred release will run and cause the dangling pointer issue.

Another minor issue is that even if the actor was not prematurely removed from the ignore list, the compare in SyncComponentsToBodies_AssumesLocked happens after a virtual “is” call on the dangling pointer.

What we ended up doing for a workaround is making a DeferredReleaseAsync function which takes an apex destructible actor pointer, a scene pointer, and which does the loop and the calls to RemoveActiveRigidActor which you posted in your answer before it does the release call.

To fix the secondary issue, we changed RemoveActiveRigidActor to RemoveActiveActor and made the ignore list contain PxActor* instead of PxRigidActor. Then we do the compare before the “is” call.

This solution fixed our issue, but I still have a concern about what happens if the async scene is still processing during the deferred release call. Is that call safe to make while the scene is active?

In any case, please let me know if you see any other potential problems with our method.

-Eric