[PATCH weston] text: Use a client destroy notifier for input method client

Derek Foreman derekf at osg.samsung.com
Tue Jun 16 15:06:42 PDT 2015


When the input method fails to launch (file not found) a wl_client is still
created, and is destroyed shortly after.

If the compositor is destroyed before the SIGHUP handler sets the client
pointer to NULL, the code that's intended to kill the input method client
on compositor shutdown can run after the wl_client is already destroyed.
This results in a segfault.

To fix this, we listen for the client destroy signal and set the
text-backend's input method client pointer to NULL when it fires so the
compositor shutdown signal won't result in trying to kill the client
again.

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 src/text-backend.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/text-backend.c b/src/text-backend.c
index 55013a2..5ec995c 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -110,6 +110,7 @@ struct text_backend {
 
 	struct wl_listener seat_created_listener;
 	struct wl_listener destroy_listener;
+	struct wl_listener client_listener;
 };
 
 static void
@@ -953,6 +954,15 @@ handle_input_method_sigchld(struct weston_process *process, int status)
 }
 
 static void
+input_method_client_notifier(struct wl_listener *listener, void *data)
+{
+	struct text_backend *text_backend =
+		container_of(listener, struct text_backend, client_listener);
+
+	text_backend->input_method.client = NULL;
+}
+
+static void
 launch_input_method(struct text_backend *text_backend)
 {
 	if (text_backend->input_method.binding)
@@ -976,6 +986,11 @@ launch_input_method(struct text_backend *text_backend)
 	if (!text_backend->input_method.client)
 		weston_log("not able to start %s\n",
 			   text_backend->input_method.path);
+
+	text_backend->client_listener.notify = input_method_client_notifier;
+	wl_client_add_destroy_listener(text_backend->input_method.client,
+				       &text_backend->client_listener);
+
 }
 
 static void
-- 
2.1.4



More information about the wayland-devel mailing list