From c528eb434371472cddaf226f15919723f9eba67e Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Mon, 29 Aug 2016 15:37:04 -0700 Subject: [PATCH weston 2/2] terminal: Fix crash due to race condition in init weston-terminal intermittently crashes on startup. This occurs because some parameters in the weston_terminal structure such as data_pitch, don't get set to non-zero until the resize_handler() callback gets triggered. That callback makes a call to terminal_resize_cells(), to calculate the proper values for these parameters. On occasion, the resize handler call is slow to resolve, and the program proceeds to start processing characters for the terminal window. With the parameters defaulting to zero, certain calculations come out wrong, leading the program to attempt to scroll the buffer when it shouldn't, and thus follows the crash. Instead, force the call to terminal_resize_cells() during the init, with some dummy defaults, to ensure the parameters are always non-zero. Signed-off-by: Bryce Harrington --- clients/terminal.c | 1 + 1 file changed, 1 insertion(+) diff --git a/clients/terminal.c b/clients/terminal.c index 284d4d5..27001cb 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -3030,6 +3030,7 @@ terminal_create(struct display *display) fprintf(stderr, "Resizing terminal to 20, 5 as default minimum\n"); terminal_resize(terminal, 20, 5); /* Set minimum size first */ + terminal_resize_cells(terminal, 20, 5); fprintf(stderr, "Resizing terminal to 80, 25\n"); terminal_resize(terminal, 80, 25); /* Set minimum size first */ -- 1.9.1