bin/92395: truss(1) does not work properly, procfs looks like
it's limited to 128 elements
Steve Sears
sjs at netapp.com
Mon Jan 30 12:20:13 PST 2006
The following reply was made to PR bin/92395; it has been noted by GNATS.
From: Steve Sears <sjs at netapp.com>
To: <bug-followup at FreeBSD.org>, <patrick.proniewski at univ-lyon2.fr>
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
> }
More information about the freebsd-bugs
mailing list