Skip to content

display-test: Fix a race condition in test suite

Fergus Dall requested to merge sidereal/wayland:tsan into main

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. This can be fixed 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

Merge request reports