]> granicus.if.org Git - strace/commitdiff
unwind: initialize unwind context only if given tcb is initialized
authorMasatake YAMATO <yamato@redhat.com>
Thu, 19 Apr 2018 08:49:47 +0000 (17:49 +0900)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 19 Apr 2018 18:03:58 +0000 (18:03 +0000)
With libdw based unwinder, following warnings are reported
when -p is passed before -k:

   $ ./strace -p 1 -k
   ...
   ./strace: dwfl_linux_proc_attach returned an error for process 0: No such file or directory
   ...

It seems that commit 54c7792b, "Fix libunwind segfault when -p is
passed before -k" doesn't fix the original issue.

* strace.c (init) [ENABLE_STACKTRACE]: Initialize unwind context only
if given tcb is initialized.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
strace.c

index f50b62568087bce393cade9ed1a5542f20cee32b..b614cfc027b5a5c0736a7220af0dd4e5e4c8b48d 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -1783,6 +1783,8 @@ init(int argc, char *argv[])
 
                unwind_init();
                for (tcbi = 0; tcbi < tcbtabsize; ++tcbi) {
+                       if (!tcbtab[tcbi]->pid)
+                               continue;
                        unwind_tcb_init(tcbtab[tcbi]);
                }
        }