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 <ldv@altlinux.org>
This commit is contained in:
Sean Stangl 2016-12-08 09:54:24 -10:00 committed by Dmitry V. Levin
parent 9555f21588
commit 54c7792bfd
2 changed files with 10 additions and 1 deletions

View File

@ -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. */

View File

@ -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();