From 370e828e526a0354911eb71b96fcb28d770eca03 Mon Sep 17 00:00:00 2001 From: Nicolas Joly <njoly@pasteur.fr> Date: Mon, 23 May 2016 11:32:38 -0700 Subject: [PATCH] Fix scancel(1) uninitialized condition variable Still testing 16.05 on my NetBSD/amd64 workstation ... Just encountered a crash with scancel(1). njoly@lanfeust [~]> sbatch --wrap "sleep 3600" Submitted batch job 4680 njoly@lanfeust [~]> scancel 4680 scancel: Error detected by libpthread: Invalid condition variable. Detected by file "/local/src/NetBSD/src/lib/libpthread/pthread_cond.c", line 140, function "pthread_cond_timedwait". See pthread(3) for information. zsh: abort (core dumped) scancel 4680 Checking the code show indeed that pthread_cond_wait() call from scancel.c:_signal_job_by_str() use an uninitialised condition variable "num_active_threads_cond" The attached patch, which add the missing pthread_cond_init() seems to fix it. bug 2753 --- src/scancel/scancel.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/scancel/scancel.c b/src/scancel/scancel.c index 11c42e99494..6f00a6f7705 100644 --- a/src/scancel/scancel.c +++ b/src/scancel/scancel.c @@ -911,6 +911,8 @@ static int _signal_job_by_str(void) if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) error("pthread_attr_setdetachstate error %m"); slurm_mutex_init(&num_active_threads_lock); + if (pthread_cond_init(&num_active_threads_cond, NULL)) + error("pthread_cond_init error %m"); for (i = 0; opt.job_list[i]; i++) { cancel_info = (job_cancel_info_t *) -- GitLab