f096bf
commit 9a447c6472947bce97e8b90b7f3f97bd7cd9f3ed
f096bf
Author: mjw <mjw@a5019735-40e9-0310-863c-91ae7b9d1cf9>
f096bf
Date:   Wed Feb 17 20:53:34 2016 +0000
f096bf
f096bf
    Bug 359201 futex syscall skips argument 5 if op is FUTEX_WAIT_BITSET
f096bf
    
f096bf
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15793 a5019735-40e9-0310-863c-91ae7b9d1cf9
f096bf
f096bf
commit f71fd226f26ab49a615d7886ff2aeadc9915c7c1
f096bf
Author: mjw <mjw@a5019735-40e9-0310-863c-91ae7b9d1cf9>
f096bf
Date:   Thu Feb 18 11:14:47 2016 +0000
f096bf
f096bf
    Bug 359201 followup. futex skips argument 5 if op is FUTEX_WAIT_BITSET.
f096bf
    
f096bf
    The original fix in svn r15793 read argument 6 separately by using PRA6
f096bf
    unconditionally. This is wrong. We need to first check whether a
f096bf
    track_pre_reg_read callback is registered (only memcheck does).
f096bf
    The PRE_REG_READX macro already had this check. Just add the same
f096bf
    before calling PRA6. Thanks to Tom Hughes for noticing. Without this
f096bf
    helgrind/tests/cond_timedwait_test and drd/tests/pth_inconsistent_cond_wait
f096bf
    regtests would fail.
f096bf
    
f096bf
    git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15795 a5019735-40e9-0310-8
f096bf
f096bf
diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c
f096bf
index f796969..f2d1076 100644
f096bf
--- a/coregrind/m_syswrap/syswrap-linux.c
f096bf
+++ b/coregrind/m_syswrap/syswrap-linux.c
f096bf
@@ -1154,13 +1154,17 @@ PRE(sys_futex)
f096bf
             return;
f096bf
       }
f096bf
       if (*(vki_u32 *)ARG1 != ARG3) {
f096bf
-         PRE_REG_READ5(long, "futex",
f096bf
+         PRE_REG_READ4(long, "futex",
f096bf
                        vki_u32 *, futex, int, op, int, val,
f096bf
-                       struct timespec *, utime, int, dummy);
f096bf
+                       struct timespec *, utime);
f096bf
       } else {
f096bf
-         PRE_REG_READ6(long, "futex",
f096bf
+        /* Note argument 5 is unused, but argument 6 is used.
f096bf
+           So we cannot just PRE_REG_READ6. Read argument 6 separately.  */
f096bf
+         PRE_REG_READ4(long, "futex",
f096bf
                        vki_u32 *, futex, int, op, int, val,
f096bf
-                       struct timespec *, utime, int, dummy, int, val3);
f096bf
+                       struct timespec *, utime);
f096bf
+         if (VG_(tdict).track_pre_reg_read)
f096bf
+            PRA6("futex",int,val3);
f096bf
       }
f096bf
       break;
f096bf
    case VKI_FUTEX_WAKE_BITSET: