[PATCH weston 04/10] compositor-wayland: fix mode_list corruption on --sprawl

Pekka Paalanen ppaalanen at gmail.com
Tue Oct 24 10:16:01 UTC 2017


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

The wayland-backend with --sprawl is one way to trigger
wayland_output_create_for_parent_output(), which intends to find a mode
from the parent mode list and use it. Calling wayland_output_set_size()
initialized an embedded struct weston_mode and inserts that into the
mode list. Then the assignment output->mode = *mode; corrupts the
mode_list by overwriting the link entry. This leads to an endless loop
in bind_output() in compositor.c.

Fix this by manually doing the setup that wayland_output_set_size() did
and do not call it.

As a side effect, it now relays the parent compositor's physical output
size to our own clients. It no longer smashes the refresh rate either.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 libweston/compositor-wayland.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index d61f08c1..c0f67e9a 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1376,18 +1376,22 @@ wayland_output_create_for_parent_output(struct wayland_backend *b,
 	output->base.scale = 1;
 	output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
 
-	if (wayland_output_set_size(&output->base, mode->width, mode->height) < 0)
-		goto out;
-
-	output->mode = *mode;
 	output->parent.output = poutput->global;
 
 	output->base.make = poutput->physical.make;
 	output->base.model = poutput->physical.model;
+	output->base.mm_width = poutput->physical.width;
+	output->base.mm_height = poutput->physical.height;
 
 	wl_list_insert_list(&output->base.mode_list, &poutput->mode_list);
 	wl_list_init(&poutput->mode_list);
 
+	/* No other mode should have CURRENT already. */
+	mode->flags |= WL_OUTPUT_MODE_CURRENT;
+	output->base.current_mode = mode;
+
+	/* output->mode is unused in this path. */
+
 	weston_compositor_add_pending_output(&output->base, b->compositor);
 
 	return 0;
-- 
2.13.6



More information about the wayland-devel mailing list