Title: [114028] trunk/Source/WTF
Revision
114028
Author
[email protected]
Date
2012-04-12 13:35:18 -0700 (Thu, 12 Apr 2012)

Log Message

ThreadingWin: Mutex::unlock() can be "over-unlocked".
https://bugs.webkit.org/show_bug.cgi?id=83725

Reviewed by David Levin.

In order to support the behavior of pthread_mutex_trylock(), the Windows Mutex class includes
a recursion counter which is incremented in Mutex::lock(), decremented in Mutex::unlock(),
and checked in Mutex::tryLock().  If the mutex is "over-unlocked", the counter wraps around to
MAX_INT, and subsequent calls to Mutex::trylock() will fail. Raise an ASSERT in this situation
so the "over-unlock" will be caught.

* wtf/ThreadingWin.cpp:
(WTF::Mutex::unlock): ASSERT if unlocking a non-locked mutex.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (114027 => 114028)


--- trunk/Source/WTF/ChangeLog	2012-04-12 20:31:51 UTC (rev 114027)
+++ trunk/Source/WTF/ChangeLog	2012-04-12 20:35:18 UTC (rev 114028)
@@ -1,3 +1,19 @@
+2012-04-12  Jer Noble  <[email protected]>
+
+        ThreadingWin: Mutex::unlock() can be "over-unlocked".
+        https://bugs.webkit.org/show_bug.cgi?id=83725
+
+        Reviewed by David Levin.
+
+        In order to support the behavior of pthread_mutex_trylock(), the Windows Mutex class includes
+        a recursion counter which is incremented in Mutex::lock(), decremented in Mutex::unlock(),
+        and checked in Mutex::tryLock().  If the mutex is "over-unlocked", the counter wraps around to
+        MAX_INT, and subsequent calls to Mutex::trylock() will fail. Raise an ASSERT in this situation
+        so the "over-unlock" will be caught.
+
+        * wtf/ThreadingWin.cpp:
+        (WTF::Mutex::unlock): ASSERT if unlocking a non-locked mutex.
+
 2012-04-10  Mark Rowe  <[email protected]>
 
         <rdar://problem/10583749> WebKit2 should log to both ASL and stderr

Modified: trunk/Source/WTF/wtf/ThreadingWin.cpp (114027 => 114028)


--- trunk/Source/WTF/wtf/ThreadingWin.cpp	2012-04-12 20:31:51 UTC (rev 114027)
+++ trunk/Source/WTF/wtf/ThreadingWin.cpp	2012-04-12 20:35:18 UTC (rev 114028)
@@ -335,6 +335,7 @@
 
 void Mutex::unlock()
 {
+    ASSERT(m_mutex.m_recursionCount);
     --m_mutex.m_recursionCount;
     LeaveCriticalSection(&m_mutex.m_internalMutex);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to