]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
For pthread_cond_destroy, don't report a false it's-still-waited-on
authorJulian Seward <jseward@acm.org>
Mon, 14 Oct 2013 12:13:52 +0000 (12:13 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 14 Oct 2013 12:13:52 +0000 (12:13 +0000)
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

helgrind/hg_intercepts.c
helgrind/hg_main.c

index 693d318ddc07489fa73af05d42bbbfcff1c12e5c..ffe08bf1b05c3fc36010a1ba2bd11bb269ce6486 100644 (file)
@@ -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) {
index 61676920ad37c53bc40b607acea2c5d9cd3e35ab..0accfe2e07da9dc737094eab8daa3992a71dc76d 100644 (file)
@@ -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: