From: Petar Jovanovic Date: Mon, 13 Nov 2017 12:12:25 +0000 (+0100) Subject: synchronize access to vgdb_interrupted_tid X-Git-Tag: VALGRIND_3_14_0~203 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=286d05eea0fc1059492bec127d4121770902c98c;p=thirdparty%2Fvalgrind.git synchronize access to vgdb_interrupted_tid 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. --- diff --git a/coregrind/m_gdbserver/m_gdbserver.c b/coregrind/m_gdbserver/m_gdbserver.c index 648d543609..24716ade19 100644 --- a/coregrind/m_gdbserver/m_gdbserver.c +++ b/coregrind/m_gdbserver/m_gdbserver.c @@ -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