You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The T2C compilation thread could set hot2 flag before compiled code was
fully visible to the main thread, causing execution of invalid function
pointers. This resulted in incorrect calculation results in the pi test.
Problem:
- volatile alone doesn't provide memory ordering guarantees
- CPU could reorder operations, making hot2=true visible before block->func
- Led to executing stale or partially written function pointers
Solution:
- Use __atomic_store_n with __ATOMIC_RELEASE when setting hot2
- Use __atomic_load_n with __ATOMIC_ACQUIRE when reading hot2
- Release-Acquire synchronization ensures proper ordering
This creates a happens-before relationship: when the main thread
observes hot2=true via acquire, it is guaranteed to see all writes
(including block->func) that happened before the release.
0 commit comments