Fix bug we added to *NSYNC a while ago

This is believed to fix a crash, that's possible in nsync_waiter_free_()
when you call pthread_cond_timedwait(), or nsync_cv_wait_with_deadline()
where an assertion can fail. Thanks ipv4.games for helping me find this!
This commit is contained in:
Justine Tunney 2024-08-26 12:25:50 -07:00
parent f3ce684aef
commit 111ec9a989
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -233,7 +233,9 @@ static int nsync_cv_wait_with_deadline_impl_ (struct nsync_cv_wait_with_deadline
/* Requeue on *pmu using existing waiter struct; current thread
is the designated waker. */
nsync_mu_lock_slow_ (c->cv_mu, c->w, MU_DESIG_WAKER, c->w->l_type);
nsync_waiter_free_ (c->w);
} else {
nsync_waiter_free_ (c->w);
/* Traditional case: We've woken from the cv, and need to reacquire *pmu. */
if (c->is_reader_mu) {
nsync_mu_rlock (c->cv_mu);
@ -241,7 +243,6 @@ static int nsync_cv_wait_with_deadline_impl_ (struct nsync_cv_wait_with_deadline
(*c->lock) (c->pmu);
}
}
nsync_waiter_free_ (c->w);
IGNORE_RACES_END ();
return (outcome);
}