Trivial changes for thread sanitizer

Thread sanitizer warns about reads and writes of variables that are
meant to be read without holding a lock:

* Global "keep_going" is now a ddsrt_atomic_uint32_t

* Thread "vtime" is now a ddsrt_atomic_uint32_t

Previously the code relied on the assumption that a 32-bit int would be
treated as atomic, now that is all wrapped in ddsrt_atomic_{ld,st}32.
These being inline functions doing exactly the same thing, there is no
functional change, but it does allow annotating the loads and stores for
via function attributes on the ddsrt_atomic_{ld,st}X.

The concurrent hashtable implementation is replaced by a locked version
of the non-concurrent implementation if thread sanitizer is used.  This
changes eliminates the scores of problems signalled by thread sanitizer
in the GUID-to-entity translation and the key-to-instance id lookups.

Other than that, this replaces a flag used in a waitset test case to be
a ddsrt_atomic_uint32_t.

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-06-07 17:49:39 +02:00 committed by eboasson
parent 0356af470d
commit c6c5a872eb
17 changed files with 404 additions and 267 deletions

View file

@ -98,8 +98,8 @@ MPT_ProcessEntry (ppud,
exp = "X";
const size_t expsz = strlen (exp);
bool eq = (usz == expsz && (usz == 0 || memcmp (ud, exp, usz) == 0));
printf ("%d: expected %u %zu/%s received %zu/%s\n",
id, exp_index, expsz, exp, usz, ud ? (char *) ud : "(null)");
//printf ("%d: expected %u %zu/%s received %zu/%s\n",
// id, exp_index, expsz, exp, usz, ud ? (char *) ud : "(null)");
MPT_ASSERT (eq, "User data mismatch: expected %u %zu/%s received %zu/%s\n",
exp_index, expsz, exp, usz, ud ? (char *) ud : "(null)");
if (strcmp (exp, "X") != 0 && ++exp_index == sizeof (exp_ud) / sizeof (exp_ud[0]))
@ -235,8 +235,8 @@ MPT_ProcessEntry (rwud,
exp = "X";
const size_t expsz = first ? 1 : strlen (exp);
bool eq = (usz == expsz && (usz == 0 || memcmp (ud, exp, usz) == 0));
printf ("%d: expected %u %zu/%s received %zu/%s\n",
id, exp_index, expsz, exp, usz, ud ? (char *) ud : "(null)");
//printf ("%d: expected %u %zu/%s received %zu/%s\n",
// id, exp_index, expsz, exp, usz, ud ? (char *) ud : "(null)");
MPT_ASSERT (eq, "User data mismatch: expected %u %zu/%s received %zu/%s\n",
exp_index, expsz, exp, usz, ud ? (char *) ud : "(null)");
if (strcmp (exp, "X") != 0 && ++exp_index == sizeof (exp_ud) / sizeof (exp_ud[0]))
@ -372,8 +372,8 @@ MPT_ProcessEntry (rwtd,
exp = "X";
const size_t expsz = first ? 1 : strlen (exp);
bool eq = (tsz == expsz && (tsz == 0 || memcmp (td, exp, tsz) == 0));
printf ("%d: expected %u %zu/%s received %zu/%s\n",
id, exp_index, expsz, exp, tsz, td ? (char *) td : "(null)");
//printf ("%d: expected %u %zu/%s received %zu/%s\n",
// id, exp_index, expsz, exp, tsz, td ? (char *) td : "(null)");
MPT_ASSERT (eq, "Topic data mismatch: expected %u %zu/%s received %zu/%s\n",
exp_index, expsz, exp, tsz, td ? (char *) td : "(null)");
if (strcmp (exp, "X") != 0 && ++exp_index == sizeof (exp_ud) / sizeof (exp_ud[0]))
@ -511,8 +511,8 @@ MPT_ProcessEntry (rwgd,
exp = "X";
const size_t expsz = first ? 1 : strlen (exp);
bool eq = (gsz == expsz && (gsz == 0 || memcmp (gd, exp, gsz) == 0));
printf ("%d: expected %u %zu/%s received %zu/%s\n",
id, exp_index, expsz, exp, gsz, gd ? (char *) gd : "(null)");
//printf ("%d: expected %u %zu/%s received %zu/%s\n",
// id, exp_index, expsz, exp, gsz, gd ? (char *) gd : "(null)");
MPT_ASSERT (eq, "Group data mismatch: expected %u %zu/%s received %zu/%s\n",
exp_index, expsz, exp, gsz, gd ? (char *) gd : "(null)");
if (strcmp (exp, "X") != 0 && ++exp_index == sizeof (exp_ud) / sizeof (exp_ud[0]))