From 3baf9ce7e80da5fc15dbc7b413f99081f344aaa9 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Wed, 11 Oct 2017 15:17:47 +0300 Subject: [PATCH] weston: arm SEGV handler earlier It is useful to print the backtrace regardless of whether we have a compositor and a backend initialized yet. Move catch_signals() to the earliest point in main() and protect the SEGV handler from dereferencing NULL when we don't yet have a compositor or a backend. The SEGV handler uses weston_log(), so cannot move catch_signals() any earlier. Signed-off-by: Pekka Paalanen Reviewed-by: Quentin Glidic Reviewed-by: Daniel Stone --- compositor/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compositor/main.c b/compositor/main.c index 9e4451e..9f00ee3 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -656,7 +656,8 @@ on_caught_signal(int s, siginfo_t *siginfo, void *context) print_backtrace(); - segv_compositor->backend->restore(segv_compositor); + if (segv_compositor && segv_compositor->backend) + segv_compositor->backend->restore(segv_compositor); raise(SIGTRAP); } @@ -1824,6 +1825,8 @@ int main(int argc, char *argv[]) weston_log_set_handler(vlog, vlog_continue); weston_log_file_open(log); + catch_signals(); + weston_log("%s\n" STAMP_SPACE "%s\n" STAMP_SPACE "Bug reports to: %s\n" @@ -1872,6 +1875,7 @@ int main(int argc, char *argv[]) weston_log("fatal: failed to create compositor\n"); goto out; } + segv_compositor = ec; if (weston_compositor_init_config(ec, config) < 0) goto out; @@ -1887,9 +1891,6 @@ int main(int argc, char *argv[]) weston_pending_output_coldplug(ec); - catch_signals(); - segv_compositor = ec; - if (idle_time < 0) weston_config_section_get_int(section, "idle-time", &idle_time, -1); if (idle_time < 0) -- 2.7.4