aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFergus Dall <sidereal@google.com>2021-12-15 10:31:41 +1100
committerSimon Ser <contact@emersion.fr>2022-02-05 14:29:39 +0000
commite949b3bfbb92363724ef1bd5b2f5736de8a9f98a (patch)
tree103dceb211bbd3356747c389732b1f060947ec01
parentUse zalloc for structs (diff)
downloadwayland-e949b3bfbb92363724ef1bd5b2f5736de8a9f98a.tar
wayland-e949b3bfbb92363724ef1bd5b2f5736de8a9f98a.tar.gz
wayland-e949b3bfbb92363724ef1bd5b2f5736de8a9f98a.tar.bz2
wayland-e949b3bfbb92363724ef1bd5b2f5736de8a9f98a.tar.lz
wayland-e949b3bfbb92363724ef1bd5b2f5736de8a9f98a.tar.xz
wayland-e949b3bfbb92363724ef1bd5b2f5736de8a9f98a.tar.zst
wayland-e949b3bfbb92363724ef1bd5b2f5736de8a9f98a.zip
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>
-rw-r--r--tests/test-compositor.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/test-compositor.h b/tests/test-compositor.h
index f763fef..7b350fe 100644
--- a/tests/test-compositor.h
+++ b/tests/test-compositor.h
@@ -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);