Skip to content

Commit ab31426

Browse files
committed
Try putting a memory barrier before the thin lock clearing to ensure that other threads observe the swapped-in and initialized lock before the thin-lock value is cleared.
1 parent 16940c3 commit ab31426

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/coreclr/vm/syncblk.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,8 @@ OBJECTHANDLE SyncBlock::GetOrCreateLock(OBJECTREF lockObj)
17651765
return existingHandle;
17661766
}
17671767

1768+
MemoryBarrier(); // Ensure that subsequent reads of m_Lock see the handle before we clear the thin lock info.
1769+
17681770
// Our lock instance is in the sync block now.
17691771
// Don't release it.
17701772
lockHandle.SuppressRelease();

0 commit comments

Comments
 (0)