From: Sean Stangl Date: Thu, 8 Dec 2016 19:54:24 +0000 (-1000) Subject: Fix libunwind segfault when -p is passed before -k X-Git-Tag: v4.15~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=54c7792b;p=strace Fix libunwind segfault when -p is passed before -k * strace.c (init) [USE_LIBUNWIND]: Call unwind_tcb_init after unwind_init for all allocated tcb structures if stack trace is enabled. * unwind.c (unwind_tcb_init): Skip if tcb is already initialized. Co-authored-by: Dmitry V. Levin --- diff --git a/strace.c b/strace.c index 1b8b5cca..56fdfdee 100644 --- a/strace.c +++ b/strace.c @@ -1769,8 +1769,14 @@ init(int argc, char *argv[]) } #ifdef USE_LIBUNWIND - if (stack_trace_enabled) + if (stack_trace_enabled) { + unsigned int tcbi; + unwind_init(); + for (tcbi = 0; tcbi < tcbtabsize; ++tcbi) { + unwind_tcb_init(tcbtab[tcbi]); + } + } #endif /* See if they want to run as another user. */ diff --git a/unwind.c b/unwind.c index 238e215d..326d184e 100644 --- a/unwind.c +++ b/unwind.c @@ -103,6 +103,9 @@ unwind_init(void) void unwind_tcb_init(struct tcb *tcp) { + if (tcp->libunwind_ui) + return; + tcp->libunwind_ui = _UPT_create(tcp->pid); if (!tcp->libunwind_ui) die_out_of_memory();