[PATCH 0/1] Add remove-without-free test

wl at ongy.net wl at ongy.net
Fri Feb 23 08:54:55 UTC 2018

From: Markus Ongyerth <wl at ongy.net>

In [1] it was pointed out, that the proposed patch breaks code, that does not
remove their listener from a wl_signal list, but just free()s them.

>From libwayland's perspective, this has never been different. People just got
wl_priv_signal_emit will touch the recently free()d memory again IFF there is
another listener behind it in the signal list.
The attached patch makes this obvious under valgrind (memcheck). I would prefer
if it failed the testcase, but I'm not sure how to do that (some sanitizer

Going forward, it would be relativly easy to add a special case for single
listener signals to the original patch, but in the rather lengthy discussion we
had earlier, we concluded that we should try to fix clients from libwayland
But this could cause problems for code that uses wl_signal and wl_signal_emit
internally, since that should actually not touch any previously called
wl_listener in the signal list (until next emit).

A secondary emit_destroy (emit_final) path as suggested in [2] seems to be the
better way.

[1] https://lists.freedesktop.org/archives/wayland-devel/2018-February/037168.html
[2] https://lists.freedesktop.org/archives/wayland-devel/2018-February/037203.html

Markus Ongyerth (1):
  tests: Add free-without-remove test

 Makefile.am                 |  3 ++
 tests/free-without-remove.c | 70 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 tests/free-without-remove.c


More information about the wayland-devel mailing list