lib/cobalt: Avoid deadlock during cancellation of pthread_cond_[timed]wait
PATCH 1/1 lib/cobalt: Avoid deadlock during cancellation of pthread_cond_[timed]wait
From: Jan Kiszka <[email protected]>
If we get canceled right after the cleanup handler was pushed but before cond_wait_prologue had a chance to run, we still own the mutex. In that case, __pthread_cond_cleanup will lock up trying to reacquire it. Detect that case and bail out early.
Fixes d282a337a069 ("Posix skin updates")
Signed-off-by Jan Kiszka <[email protected]>
---
And another one from that area. This one dates back to a commit done 19(!) years ago.
lib/cobalt/cond.c | 5 +++++ 1 file changed, 5 insertions(+)
lib/cobalt/cond.c +5 -0
@@ -218,8 +218,13 @@ struct cobalt_cond_cleanup_t {static void __pthread_cond_cleanup (void *data) {struct cobalt_cond_cleanup_t *c = (struct cobalt_cond_cleanup_t *)data; +xnhandle_t cur =cobalt_get_current ();int err; +/* if we still own the mutex, cond_wait_prologue wasn't called yet */ +if (xnsynch_fast_owner_check (mutex_get_ownerp (c->mutex), cur) ==0 ) +return ; + do { err = XENOMAI_SYSCALL2(sc_cobalt_cond_wait_epilogue, c->cond, c->mutex);
Signature · 1 line
2.43.0