Index: synchronization/condition_variable_posix.cc |
diff --git a/synchronization/condition_variable_posix.cc b/synchronization/condition_variable_posix.cc |
index 013284c888f72993b81a75f0b56a28bd653e6e3a..c9a2ec43f829e7fdbb73351e8739ad5e699150eb 100644 |
--- a/synchronization/condition_variable_posix.cc |
+++ b/synchronization/condition_variable_posix.cc |
@@ -42,6 +42,20 @@ ConditionVariable::ConditionVariable(Lock* user_lock) |
} |
ConditionVariable::~ConditionVariable() { |
+#if defined(OS_MACOSX) |
+ // This hack is necessary to avoid a fatal pthreads subsystem bug in the |
+ // Darwin kernel. http://crbug.com/517681. |
+ { |
+ base::Lock lock; |
+ base::AutoLock l(lock); |
+ struct timespec ts; |
+ ts.tv_sec = 0; |
+ ts.tv_nsec = 1; |
+ pthread_cond_timedwait_relative_np(&condition_, lock.lock_.native_handle(), |
+ &ts); |
+ } |
+#endif |
+ |
int rv = pthread_cond_destroy(&condition_); |
DCHECK_EQ(0, rv); |
} |