@@ -644,7 +644,7 @@ bool CLRLifoSemaphore::WaitForSignal(DWORD timeoutMs)
644644
645645 _ASSERTE (timeoutMs != 0 );
646646 _ASSERTE (m_handle != nullptr );
647- _ASSERTE (m_counts.waiterCount != (UINT16)0 );
647+ _ASSERTE (m_counts.VolatileLoadWithoutBarrier (). waiterCount != (UINT16)0 );
648648
649649 while (true )
650650 {
@@ -680,7 +680,7 @@ bool CLRLifoSemaphore::WaitForSignal(DWORD timeoutMs)
680680 }
681681
682682 // Unregister the waiter if this thread will not be waiting anymore, and try to acquire the semaphore
683- Counts counts = m_counts;
683+ Counts counts = m_counts. VolatileLoadWithoutBarrier () ;
684684 while (true )
685685 {
686686 _ASSERTE (counts.waiterCount != (UINT16)0 );
@@ -719,7 +719,7 @@ bool CLRLifoSemaphore::Wait(DWORD timeoutMs)
719719 _ASSERTE (m_handle != nullptr );
720720
721721 // Acquire the semaphore or register as a waiter
722- Counts counts = m_counts;
722+ Counts counts = m_counts. VolatileLoadWithoutBarrier () ;
723723 while (true )
724724 {
725725 _ASSERTE (counts.signalCount <= m_maximumSignalCount);
@@ -762,7 +762,7 @@ bool CLRLifoSemaphore::Wait(DWORD timeoutMs, UINT32 spinCount, UINT32 processorC
762762 }
763763
764764 // Try to acquire the semaphore or register as a spinner
765- Counts counts = m_counts;
765+ Counts counts = m_counts. VolatileLoadWithoutBarrier () ;
766766 while (true )
767767 {
768768 Counts newCounts = counts;
@@ -809,7 +809,7 @@ bool CLRLifoSemaphore::Wait(DWORD timeoutMs, UINT32 spinCount, UINT32 processorC
809809 ClrSleepEx (0 , false );
810810
811811 // Try to acquire the semaphore and unregister as a spinner
812- counts = m_counts;
812+ counts = m_counts. VolatileLoadWithoutBarrier () ;
813813 while (true )
814814 {
815815 _ASSERTE (counts.spinnerCount != (UINT8)0 );
@@ -868,7 +868,7 @@ bool CLRLifoSemaphore::Wait(DWORD timeoutMs, UINT32 spinCount, UINT32 processorC
868868 }
869869
870870 // Try to acquire the semaphore and unregister as a spinner
871- counts = m_counts;
871+ counts = m_counts. VolatileLoadWithoutBarrier () ;
872872 while (true )
873873 {
874874 _ASSERTE (counts.spinnerCount != (UINT8)0 );
@@ -893,7 +893,7 @@ bool CLRLifoSemaphore::Wait(DWORD timeoutMs, UINT32 spinCount, UINT32 processorC
893893#endif // _TARGET_ARM64_
894894
895895 // Unregister as a spinner, and acquire the semaphore or register as a waiter
896- counts = m_counts;
896+ counts = m_counts. VolatileLoadWithoutBarrier () ;
897897 while (true )
898898 {
899899 _ASSERTE (counts.spinnerCount != (UINT8)0 );
@@ -934,7 +934,7 @@ void CLRLifoSemaphore::Release(INT32 releaseCount)
934934 _ASSERTE (m_handle != INVALID_HANDLE_VALUE);
935935
936936 INT32 countOfWaitersToWake;
937- Counts counts = m_counts;
937+ Counts counts = m_counts. VolatileLoadWithoutBarrier () ;
938938 while (true )
939939 {
940940 Counts newCounts = counts;
0 commit comments