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
There is a defect in Wintellect.Threading.ResourceLocks.ResourceLock.Leave where write lock leakage can easily occur in high concurrency scenarios.
The Enter method first acquires the lock and then increments the counter, while the Leave method first releases the lock and then decrements the counter.
This introduces a possibility where, assuming thousands of threads are executing read locks simultaneously and releasing them, and at that moment, one thread acquires a write lock and immediately releases it. In this scenario, it is possible that the counter for the read locks has not yet completed the subtraction operation. When the Leave method is called on this write lock, it mistakenly treats it as a read lock and releases it accordingly. This triggers an exception stating "Read lock was not held when attempting to release," resulting in write lock leakage.
To address this issue, the Leave method should be modified to place the lock release operation (OnLeave(exclusive)) at the bottom. This ensures the atomicity of the lock.
The text was updated successfully, but these errors were encountered:
There is a defect in Wintellect.Threading.ResourceLocks.ResourceLock.Leave where write lock leakage can easily occur in high concurrency scenarios.
The Enter method first acquires the lock and then increments the counter, while the Leave method first releases the lock and then decrements the counter.
This introduces a possibility where, assuming thousands of threads are executing read locks simultaneously and releasing them, and at that moment, one thread acquires a write lock and immediately releases it. In this scenario, it is possible that the counter for the read locks has not yet completed the subtraction operation. When the Leave method is called on this write lock, it mistakenly treats it as a read lock and releases it accordingly. This triggers an exception stating "Read lock was not held when attempting to release," resulting in write lock leakage.
To address this issue, the Leave method should be modified to place the lock release operation (OnLeave(exclusive)) at the bottom. This ensures the atomicity of the lock.
The text was updated successfully, but these errors were encountered: