]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
synchronize access to vgdb_interrupted_tid
authorPetar Jovanovic <mips32r2@gmail.com>
Mon, 13 Nov 2017 12:12:25 +0000 (13:12 +0100)
committerPetar Jovanovic <mips32r2@gmail.com>
Mon, 13 Nov 2017 12:13:28 +0000 (13:13 +0100)
Delay writing to the global vgdb_interrupted_tid until all the threads are
in interruptible state. This ensures that valgrind_wait() will see correct
value.

This solves occasional failures of gdbserver_tests/hgtls test.

coregrind/m_gdbserver/m_gdbserver.c

index 648d5436094d68d61759ad7efcc32b437787c626..24716ade1919e2fc627b6d53ad84a21cdbb329ca 100644 (file)
@@ -876,7 +876,7 @@ void VG_(invoke_gdbserver) ( int check )
       gdbserver. Otherwise, we let the valgrind scheduler invoke
       gdbserver at the next poll.  This poll will be made very soon
       thanks to a call to VG_(force_vgdb_poll). */
-   int n_tid;
+   int n_tid, vgdb_interrupted_tid_local = 0;
 
    vg_assert (check == 0x8BADF00D);
 
@@ -894,7 +894,8 @@ void VG_(invoke_gdbserver) ( int check )
       /* interruptible states. */
       case VgTs_WaitSys:
       case VgTs_Yielding:
-         if (vgdb_interrupted_tid == 0) vgdb_interrupted_tid = n_tid;
+         if (vgdb_interrupted_tid_local == 0)
+            vgdb_interrupted_tid_local = n_tid;
          break;
 
       case VgTs_Empty:     
@@ -912,6 +913,8 @@ void VG_(invoke_gdbserver) ( int check )
       }
    }
 
+   vgdb_interrupted_tid = vgdb_interrupted_tid_local;
+
    /* .... till here.
       From here onwards, function calls are ok: it is
       safe to call valgrind core functions: all threads are blocked in