[PATCH] unwind: initialize unwind context only if given tcb is initialized

Masatake YAMATO yamato at redhat.com
Thu Apr 19 08:49:47 UTC 2018


With libdw based unwinder, following warnings are reported
when -p is passed before -k:

   $ sudo ./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 at redhat.com>
---
 strace.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/strace.c b/strace.c
index f50b6256..b614cfc0 100644
--- 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]);
 		}
 	}
-- 
2.14.3



More information about the Strace-devel mailing list