Commit fd2dbf1d authored by jkummerow's avatar jkummerow Committed by Commit bot

[Mac] Work around potential pthread_mutex_destroy crashes

This ports https://codereview.chromium.org/1323293005 to V8.
I'm not aware of any evidence that such crashes are currently
happening, but it's probably good to ship this workaround anyway.

BUG=chromium:517681
LOG=n

Review-Url: https://codereview.chromium.org/1959643002
Cr-Commit-Position: refs/heads/master@{#36087}
parent 3181c87e
......@@ -36,6 +36,19 @@ ConditionVariable::ConditionVariable() {
ConditionVariable::~ConditionVariable() {
#if defined(V8_OS_MACOSX)
// This hack is necessary to avoid a fatal pthreads subsystem bug in the
// Darwin kernel. http://crbug.com/517681.
{
Mutex lock;
LockGuard<Mutex> l(&lock);
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 1;
pthread_cond_timedwait_relative_np(&native_handle_, &lock.native_handle(),
&ts);
}
#endif
int result = pthread_cond_destroy(&native_handle_);
DCHECK_EQ(0, result);
USE(result);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment