Skip to content

Commit

Permalink
More specific assertion for unlocking mutex not owned by the current …
Browse files Browse the repository at this point in the history
…thread (#5099)
  • Loading branch information
AlexGuteniev authored Nov 22, 2024
1 parent fec1c8b commit 9b8a09a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion stl/src/mutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ static _Thrd_result mtx_do_lock(_Mtx_t mtx, const _timespec64* target) noexcept
}

_CRTIMP2_PURE _Thrd_result __cdecl _Mtx_unlock(_Mtx_t mtx) noexcept { // unlock mutex
_THREAD_ASSERT(mtx->_Count > 0, "unlock of unowned mutex");
_THREAD_ASSERT(
1 <= mtx->_Count && mtx->_Thread_id == static_cast<long>(GetCurrentThreadId()), "unlock of unowned mutex");
mtx->_Thread_id == static_cast<long>(GetCurrentThreadId()), "unlock of mutex not owned by the current thread");

if (--mtx->_Count == 0) { // leave critical section
mtx->_Thread_id = -1;
Expand Down

0 comments on commit 9b8a09a

Please sign in to comment.