From 0f21f5285b755652faf5f371d455e10da87741f0 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 2 Aug 2016 22:47:06 +0000 Subject: [PATCH] truss: fix uninitialized trussinfo->curthread in add_threads()/enter_syscall trussinfo->curthread must be initialized before calling enter_syscall(), it is used by t->proc->abi->fetch_args(). Without that truss is segfaulting and the attached program also crash. Submitted by: Nikita Kozlov (nikita@gandi.net) Reviewed by: jhb MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D7399 --- usr.bin/truss/setup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.bin/truss/setup.c b/usr.bin/truss/setup.c index c134405907d3..a14c01664ef5 100644 --- a/usr.bin/truss/setup.c +++ b/usr.bin/truss/setup.c @@ -223,8 +223,10 @@ add_threads(struct trussinfo *info, struct procinfo *p) t = new_thread(p, lwps[i]); if (ptrace(PT_LWPINFO, lwps[i], (caddr_t)&pl, sizeof(pl)) == -1) err(1, "ptrace(PT_LWPINFO)"); - if (pl.pl_flags & PL_FLAG_SCE) + if (pl.pl_flags & PL_FLAG_SCE) { + info->curthread = t; enter_syscall(info, t, &pl); + } } free(lwps); }