From e949b3bfbb92363724ef1bd5b2f5736de8a9f98a Mon Sep 17 00:00:00 2001 From: Fergus Dall Date: Wed, 15 Dec 2021 10:31:41 +1100 Subject: [PATCH] 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 --- tests/test-compositor.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test-compositor.h b/tests/test-compositor.h index f763fef3..7b350fe9 100644 --- a/tests/test-compositor.h +++ b/tests/test-compositor.h @@ -25,6 +25,7 @@ #include #include +#include #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);