From 54c7792bfdcc802b09dec4d99cc5517a524b11d6 Mon Sep 17 00:00:00 2001 From: Sean Stangl Date: Thu, 8 Dec 2016 09:54:24 -1000 Subject: [PATCH] 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 --- strace.c | 8 +++++++- unwind.c | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) 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(); -- 2.40.0