From owner-freebsd-bugs@FreeBSD.ORG Mon Jan 30 20:20:12 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E958F16A422 for ; Mon, 30 Jan 2006 20:20:12 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 383BE43D75 for ; Mon, 30 Jan 2006 20:20:06 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k0UKK6Fb089974 for ; Mon, 30 Jan 2006 20:20:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k0UKK6A1089973; Mon, 30 Jan 2006 20:20:06 GMT (envelope-from gnats) Date: Mon, 30 Jan 2006 20:20:06 GMT Message-Id: <200601302020.k0UKK6A1089973@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Steve Sears Cc: Subject: Re: bin/92395: truss(1) does not work properly, procfs looks like it's limited to 128 elements X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Steve Sears List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jan 2006 20:20:13 -0000 The following reply was made to PR bin/92395; it has been noted by GNATS. From: Steve Sears To: , Cc: Subject: Re: bin/92395: truss(1) does not work properly, procfs looks like it's limited to 128 elements Date: Mon, 30 Jan 2006 15:18:19 -0500 I fixed a problem in truss that seems related to some of what you are seeing in this PR. The problem I fixed has to do with the number of arguments truss reads for a syscall from the kernel. There are a number of conditions that will cause the arguments returned from the ioctl to be wrong - it is often a signal number and not the number of arguments at all. Fortunately, truss has a table with all of the commands and the number of arguments they take. Obtain the argument count from the table instead of relying on the ioctl and things work much better. My fixes: ==== ./usr/src/usr.bin/truss/i386-fbsd.c#2 (text) ==== 175,182c175,178 < if (nargs == 0) < return; < < fsc.args = malloc((1+nargs) * sizeof(unsigned long)); < lseek(Procfd, parm_offset, SEEK_SET); < if (read(Procfd, fsc.args, nargs * sizeof(unsigned long)) == -1) < return; < --- > /* The passed in nargs is not always reliable, it can be affected by > * signals and other things going on in the kernel. Only use it in > * the last resort. > */ 185a182 > nargs = sc->nargs; 193a191,199 > if (nargs == 0) > return; > > fsc.args = malloc((1+nargs) * sizeof(unsigned long)); > lseek(Procfd, parm_offset, SEEK_SET); > if (read(Procfd, fsc.args, nargs * sizeof(unsigned long)) == -1) > return; > > 207d212 < ==== ./usr/src/usr.bin/truss/syscalls.c#3 (text) ==== 231c231 < buf = malloc( size = (max ? max : 64 ) ); --- > buf = malloc( size = (max ? max + 1 : 64 ) ); 238d237 < buf[len] = 0; 251a251 > buf[len] = 0; 416c416 < if ((pfd = malloc(bytes)) == NULL) --- > if ((pfd = malloc(bytes)) == NULL) { 417a418 > }