From: Julian Seward Date: Mon, 14 Oct 2013 12:13:52 +0000 (+0000) Subject: For pthread_cond_destroy, don't report a false it's-still-waited-on X-Git-Tag: svn/VALGRIND_3_9_0~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d23025ac42a060f00d7a6787e1453d5115be029c;p=thirdparty%2Fvalgrind.git For pthread_cond_destroy, don't report a false it's-still-waited-on error if in fact the last wait finished with ETIMEDOUT. Fixes #324149. (Peter Boström, valgrind@pbos.me) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13641 --- diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c index 693d318ddc..ffe08bf1b0 100644 --- a/helgrind/hg_intercepts.c +++ b/helgrind/hg_intercepts.c @@ -685,8 +685,8 @@ static int pthread_cond_wait_WRK(pthread_cond_t* cond, } if (ret == 0 && mutex_is_valid) { - DO_CREQ_v_WW(_VG_USERREQ__HG_PTHREAD_COND_WAIT_POST, - pthread_cond_t*,cond, pthread_mutex_t*,mutex); + DO_CREQ_v_WWW(_VG_USERREQ__HG_PTHREAD_COND_WAIT_POST, + pthread_cond_t*,cond, pthread_mutex_t*,mutex, long,0); } if (ret != 0) { @@ -773,9 +773,10 @@ static int pthread_cond_timedwait_WRK(pthread_cond_t* cond, pthread_mutex_t*,mutex); } - if (ret == 0 && mutex_is_valid) { - DO_CREQ_v_WW(_VG_USERREQ__HG_PTHREAD_COND_WAIT_POST, - pthread_cond_t*,cond, pthread_mutex_t*,mutex); + if ((ret == 0 || ret == ETIMEDOUT) && mutex_is_valid) { + DO_CREQ_v_WWW(_VG_USERREQ__HG_PTHREAD_COND_WAIT_POST, + pthread_cond_t*,cond, pthread_mutex_t*,mutex, + long,ret == ETIMEDOUT); } if (ret != 0 && ret != ETIMEDOUT) { diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c index 61676920ad..0accfe2e07 100644 --- a/helgrind/hg_main.c +++ b/helgrind/hg_main.c @@ -2329,7 +2329,8 @@ static Bool evh__HG_PTHREAD_COND_WAIT_PRE ( ThreadId tid, } static void evh__HG_PTHREAD_COND_WAIT_POST ( ThreadId tid, - void* cond, void* mutex ) + void* cond, void* mutex, + Bool timeout) { /* A pthread_cond_wait(cond, mutex) completed successfully. Find the SO for this cond, and 'recv' from it so as to acquire a @@ -2339,8 +2340,8 @@ static void evh__HG_PTHREAD_COND_WAIT_POST ( ThreadId tid, if (SHOW_EVENTS >= 1) VG_(printf)("evh__HG_PTHREAD_COND_WAIT_POST" - "(ctid=%d, cond=%p, mutex=%p)\n", - (Int)tid, (void*)cond, (void*)mutex ); + "(ctid=%d, cond=%p, mutex=%p)\n, timeout=%d", + (Int)tid, (void*)cond, (void*)mutex, (Int)timeout ); thr = map_threads_maybe_lookup( tid ); tl_assert(thr); /* cannot fail - Thread* must already exist */ @@ -2362,7 +2363,7 @@ static void evh__HG_PTHREAD_COND_WAIT_POST ( ThreadId tid, tl_assert(cvi->so); tl_assert(cvi->nWaiters > 0); - if (!libhb_so_everSent(cvi->so)) { + if (!timeout && !libhb_so_everSent(cvi->so)) { /* Hmm. How can a wait on 'cond' succeed if nobody signalled it? If this happened it would surely be a bug in the threads library. Or one of those fabled "spurious wakeups". */ @@ -4874,7 +4875,8 @@ Bool hg_handle_client_request ( ThreadId tid, UWord* args, UWord* ret) mutex=arg[2] */ case _VG_USERREQ__HG_PTHREAD_COND_WAIT_POST: evh__HG_PTHREAD_COND_WAIT_POST( tid, - (void*)args[1], (void*)args[2] ); + (void*)args[1], (void*)args[2], + (Bool)args[3] ); break; case _VG_USERREQ__HG_PTHREAD_RWLOCK_INIT_POST: