Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: base/synchronization/lock_impl_posix.cc

Issue 8414031: Temporary instrumentation to help understand lock errors on mac debug bots. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Add a log message pointing to bug Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/synchronization/lock_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/synchronization/lock_impl_posix.cc
===================================================================
--- base/synchronization/lock_impl_posix.cc (revision 107048)
+++ base/synchronization/lock_impl_posix.cc (working copy)
@@ -12,6 +12,10 @@
namespace internal {
LockImpl::LockImpl() {
+#ifdef LOCK_IMPL_CHECK_LIVENESS
+ liveness_token_ = LT_ALIVE;
+#endif
+
#ifndef NDEBUG
// In debug, setup attributes for lock error checking.
pthread_mutexattr_t mta;
@@ -30,25 +34,45 @@
}
LockImpl::~LockImpl() {
+#ifdef LOCK_IMPL_CHECK_LIVENESS
+ CheckIsAlive();
+ liveness_token_ = LT_DELETED;
+#endif
int rv = pthread_mutex_destroy(&os_lock_);
DCHECK_EQ(rv, 0);
}
bool LockImpl::Try() {
+#ifdef LOCK_IMPL_CHECK_LIVENESS
+ CheckIsAlive();
+#endif
int rv = pthread_mutex_trylock(&os_lock_);
DCHECK(rv == 0 || rv == EBUSY);
return rv == 0;
}
void LockImpl::Lock() {
+#ifdef LOCK_IMPL_CHECK_LIVENESS
+ CheckIsAlive();
+#endif
int rv = pthread_mutex_lock(&os_lock_);
DCHECK_EQ(rv, 0);
}
void LockImpl::Unlock() {
+#ifdef LOCK_IMPL_CHECK_LIVENESS
+ CheckIsAlive();
+#endif
int rv = pthread_mutex_unlock(&os_lock_);
DCHECK_EQ(rv, 0);
}
+#ifdef LOCK_IMPL_CHECK_LIVENESS
+void LockImpl::CheckIsAlive() {
+ CHECK_EQ(LT_ALIVE, liveness_token_)
+ << "Lock was invalid. Please see: http://crbug.com/102161";
+}
+#endif
+
} // namespace internal
} // namespace base
« no previous file with comments | « base/synchronization/lock_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698