From 31377765dbbb8d49292c4362837a695adcbc6cb4 Mon Sep 17 00:00:00 2001 From: Jeff Darcy Date: Mon, 20 Mar 2017 12:31:33 -0400 Subject: core: fix synclocks' handling of "woken" flag The "woken" flag wasn't being reset when it should have been, leading (eventually) to a SEGV when someone tried to folow a synclock's waitq to a task structure that had been freed while still on the queue. See the bug report for (far) more detail. Change-Id: I5cd9ae1bcb831555274108b292181ec2a29b6d95 BUG: 1434062 Signed-off-by: Jeff Darcy Reviewed-on: https://review.gluster.org/16926 NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Smoke: Gluster Build System Reviewed-by: Amar Tumballi --- libglusterfs/src/syncop.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 93f60535587..021834ed42d 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -660,8 +660,8 @@ synctask_switchto (struct synctask *task) #endif if (swapcontext (&task->proc->sched, &task->ctx) < 0) { - gf_msg ("syncop", GF_LOG_ERROR, errno, LG_MSG_SWAPCONTEXT_FAILED, - "swapcontext failed"); + gf_msg ("syncop", GF_LOG_ERROR, errno, + LG_MSG_SWAPCONTEXT_FAILED, "swapcontext failed"); } if (task->state == SYNCTASK_DONE) { @@ -915,6 +915,7 @@ __synclock_lock (struct synclock *lock) while (lock->lock) { if (task) { /* called within a synctask */ + task->woken = 0; list_add_tail (&task->waitq, &lock->waitq); pthread_mutex_unlock (&lock->guard); synctask_yield (task); -- cgit