display-test: Fix a race condition in test suite

Several tests in this suite use setting and checking client.display_stopped (in
test-compositor.h) to synchronise between threads. This is a data race because
display_stopped is a non-atomic int. Fix this by making it an atomic_bool
instead. We don't need to change the access code because reads and writes are
sequentially consistent by default.

This can be reproduced (with both clang and gcc) by running
```
meson -Db_sanitize=thread build
cd build
ninja
meson test
```

Signed-off-by: Fergus Dall <sidereal@google.com>
This commit is contained in:
Fergus Dall 2021-12-15 10:31:41 +11:00 committed by Simon Ser
parent 5eb5620cbd
commit e949b3bfbb

View file

@ -25,6 +25,7 @@
#include <stdint.h>
#include <unistd.h>
#include <stdatomic.h>
#include "wayland-server.h"
#include "wayland-client.h"
@ -65,7 +66,7 @@ struct client {
struct wl_display *wl_display;
struct test_compositor *tc;
int display_stopped;
atomic_bool display_stopped;
};
struct client *client_connect(void);