Files
UnrealEngineUWP/Engine/Source/Runtime/Core/Public/Async
denys mentiei 0dc15c6085 [EventCount] Race fix
There was a race possible between FPipe::WaitUntilEmpty and FPipe::ClearTask() which was caused by a race in EventCount between Notify & Wait.

That led to a dead-lock on IOS.

Fixed by adding a StoreLoad (kinda) barrier into Notify to ensure the proper memory ordering for Counter value.
RMW is used as a barrier, but could also be solved with a few seq_cst fences (considered to be less optimal and unsupported by TSan).

More details:

Thread 1:
- ClearTask: fetch_sub-s TaskCount to 0 and goes Notify
- Notify: reads count as 0 and exits without any wakes (first bit is not set -> nobody is waiting)
Thead 2:
- WaitUntilEmpty: first check fails, second check check fails, calls PrepareWait (sets count to 1, returns 0), calls WaitFor with 0
- WaitFor: gets count as 1, count without 1 bit is 0, matches token -> wait for Notify which will never happen.

One thread was reading stale data due to memory reordering.

#rb anderson.ramos, danny.couture, Devin.Doucette
#rnx

[CL 36755848 by denys mentiei in 5.5 branch]
2024-10-01 19:11:19 -04:00
..
2024-10-01 19:11:19 -04:00