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

Dmitry V. Levin ldv at altlinux.org
Thu Apr 19 22:44:51 UTC 2018


On Thu, Apr 19, 2018 at 05:49:47PM +0900, Masatake YAMATO wrote:
> 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.

Applied, thanks!

> --- 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]);
>  		}
>  	}

Apparently, we don't need this loop at all, there is no use to call
unwind_tcb_init until the tracee is actually attached.  The proper place
for unwind_tcb_init invocation is the same as for newoutf.
I've pushed a few commits to implement this change.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20180420/538b7dc6/attachment.bin>


More information about the Strace-devel mailing list