From f1a64f7c75fdc6a0ebea71ed2827d3dbc12761b5 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. Backport of: > Commit 31377765dbbb8d49292c4362837a695adcbc6cb4 > BUG: 1434062 > Reviewed-on: https://review.gluster.org/16926 Change-Id: I5cd9ae1bcb831555274108b292181ec2a29b6d95 BUG: 1441474 Signed-off-by: Jeff Darcy Reviewed-on: https://review.gluster.org/17043 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Atin Mukherjee Reviewed-by: Shyamsundar Ranganathan --- 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 00a9b576269..4e76587acda 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) { @@ -913,6 +913,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