[PATCH] Two smallish and an a bit more subtle one

Jeremy Allison jra at samba.org
Mon Oct 17 17:36:43 UTC 2016


On Mon, Oct 17, 2016 at 05:23:30PM +0200, Volker Lendecke wrote:
> 
> From fa5d14deb8ceff86df497f6ffb4459d6e91ed341 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Mon, 17 Oct 2016 17:09:01 +0200
> Subject: [PATCH 3/3] lib: Fix a pthreadpool race condition
> 
> Yes, there is one.... I've seen two flaky builds on sn-devel with
> pthreadpool after the coverity checks went in. They were in the
> 
> 		ret = pthread_mutex_unlock(&pool->mutex);
> 		assert(ret == 0);
> 
> in pthreadpool_parent() and pthreadpool_child(). No idea what that was,
> I could not really reproduce that. A build attempt on FreeBSD also gave
> an erratic error, this time it was an EINVAL in
> 
> 		ret = pthread_mutex_lock(&pool->mutex);
> 		assert(ret == 0);
> 
> pthreadpool_parent(). EINVAL means that the mutex is not a proper
> mutex. What happened: Someone (a detached thread) does the
> pthreadpool_free behind our back, while we are in pthreadpool_parent,
> preparing the fork. Unfortunately the mutex was already destroyed before
> we came to lock it.
> 
> The fix is simple: Remove the obsolete struct pthreadpool from the
> linked list before the mutex is destroyed.

Wow. That one was subtle. Sorry for not seeing that in the review !

Jeremy.



More information about the samba-technical mailing list