Crash in SparseArray / MovieSceneTransformOriginSystem

It seems another thread must have modified the SparseArray:

UMovieSceneTransformOriginSystem::TransformOriginsByInstanceID

..while it was being inserted into, in the call stack provided - see comments on the screenshot.

Any help at all would be appreciated!

-Finn

This question was created in reference to: [MovieSceneTransformOriginSystem memory corruption (crash with [Content removed]

[Attachment Removed]

Steps to Reproduce
Activating a quite complex Sequence in our game, happens after a couple of seconds 100%

[Attachment Removed]

[Attachment Removed]

Hi there,

It looks like we are going wide with FGatherTransformOriginsFromSubscenes due to using Fork_PerAllocation when building the task in UMovieSceneTransformOriginSystem::OnSchedulePersistentTasks

But it’s writing to the sparse array, so that behavior isn’t thread safe.

Can you test using Schedule_PerAllocation for FGatherTransformOriginsFromSubscenes instead to see if that resolves the issue? This should schedule the tasks so they run serially instead of in parallel, which should prevent two threads from writing to the sparse array at the same time.

Thanks!

[Attachment Removed]

Hi Austin,

Thanks for that very precise response. I tested your proposed fix on my good repro, and the crash no longer happens!

I will patch this in our current 5.6.1. Is there any chance you will patch it in 5.7?

Thanks again:-)

-Finn

[Attachment Removed]

You’re welcome!

Thanks for verifying this fix. I’ve put it in for a code review, but it looks like this will likely be in 5.8 at the earliest.

Seems like I never exceeded the allocation size with sub-sequences during my tests, so fork and schedule were behaving the same. Thanks for bringing this up; this flew under the radar for a while!

[Attachment Removed]

I’ve submitted the fix into UE5 Main as CL 49417799. This will make its way into 5.8.

[Attachment Removed]