summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkosak@google.com <kosak@google.com@861a406c-534a-0410-8894-cb66d6ee9925>2015-02-14 02:13:32 +0000
committerkosak@google.com <kosak@google.com@861a406c-534a-0410-8894-cb66d6ee9925>2015-02-14 02:13:32 +0000
commitd4984975ee0bdd68aeb9dfbc00258cce534b5a9b (patch)
tree7aec0ef4659f22086b75246601d9e5272abf5f73
parent1db4d3aae54220356fcc0b77fdaad023ec352a16 (diff)
downloadgoogletest-d4984975ee0bdd68aeb9dfbc00258cce534b5a9b.tar.gz
Add asserts to prevent mysterious hangs in a non-thread-safe gmock build.
git-svn-id: http://googletest.googlecode.com/svn/trunk@706 861a406c-534a-0410-8894-cb66d6ee9925
-rw-r--r--include/gtest/internal/gtest-linked_ptr.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/include/gtest/internal/gtest-linked_ptr.h b/include/gtest/internal/gtest-linked_ptr.h
index b1362cd..3602942 100644
--- a/include/gtest/internal/gtest-linked_ptr.h
+++ b/include/gtest/internal/gtest-linked_ptr.h
@@ -110,7 +110,12 @@ class linked_ptr_internal {
MutexLock lock(&g_linked_ptr_mutex);
linked_ptr_internal const* p = ptr;
- while (p->next_ != ptr) p = p->next_;
+ while (p->next_ != ptr) {
+ assert(p->next_ != this &&
+ "Trying to join() a linked ring we are already in. "
+ "Is GMock thread safety enabled?");
+ p = p->next_;
+ }
p->next_ = this;
next_ = ptr;
}
@@ -123,7 +128,12 @@ class linked_ptr_internal {
if (next_ == this) return true;
linked_ptr_internal const* p = next_;
- while (p->next_ != this) p = p->next_;
+ while (p->next_ != this) {
+ assert(p->next_ != next_ &&
+ "Trying to depart() a linked ring we are not in. "
+ "Is GMock thread safety enabled?");
+ p = p->next_;
+ }
p->next_ = next_;
return false;
}