[prev in list] [next in list] [prev in thread] [next in thread] 

List:       netbsd-bugs
Subject:    bin/26452: ps(1) use too many spaces for LID display on 64bit platforms
From:       njoly () pasteur1 ! fr
Date:       2004-07-27 21:43:53
Message-ID: 20040727214353.CB1576B403 () lanfeust ! sis ! pasteur ! fr
[Download RAW message or body]


> Number:         26452
> Category:       bin
> Synopsis:       ps(1) use too many spaces for LID display on 64bit platforms
> Confidential:   no
> Severity:       non-critical
> Priority:       low
> Responsible:    bin-bug-people
> State:          open
> Class:          sw-bug
> Submitter-Id:   net
> Arrival-Date:   Tue Jul 27 21:44:00 UTC 2004
> Closed-Date:
> Last-Modified:
> Originator:     Nicolas Joly
> Release:        NetBSD 2.0G
> Organization:
	Institut Pasteur
> Environment:
System: NetBSD lanfeust.sis.pasteur.fr 2.0G NetBSD 2.0G (LANFEUST) #11: Tue Jul 27 \
00:06:31 CEST 2004 njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj/amd64/sys/arch/amd64/compile/LANFEUST \
                amd64
Architecture: x86_64
Machine: amd64
> Description:
The ps(1) command seems to have a problem with the LID column display on 64
bits platforms (at least on alpha and amd64). The calculated column width
is wrong, which leads in extra spaces on display.

njoly@lanfeust [tmp/ps]> ps -s
 UID  PID PPID CPU          LID NLWP PRI NI VSZ  RSS WCHAN  STAT TT    TIME COMMAND
1000 2535 3486   0            1    1  18  0 220 2116 pause  I    p1 0:00.55 -zs
1000 2801 2535   0            1    1   2  0 240 1224 poll   S    p1 0:17.41 top
1000 1619 1854   0            1    1  18  0 224 2156 pause  I    p2 0:00.01 -zs
1000 2851 1619   0            1    1   2  0 104  704 kqread I    p2 0:00.00 tai
1000 2164 2981   0            1    1   3  0 304 2244 ttyin  I    p3 0:00.07 -zs
1000 3746 4408   0            1    1  18  0 220 2164 pause  S    p4 0:00.02 -zs
1000 5210 3746   0            1    1  28  0  92  784 -      R    p4 0:00.00 ./p
1000 2209 1835   0            1    1  18  0 304 2232 pause  I    p5 0:00.02 -zs
1000 3762 2209   6            1    1  10  0 208 1040 wait   I    p5 0:00.01 /bi
1000 4986 3762   0            1    1   3  0 668 1640 ttyin  S    p5 0:00.04 vi 

I noticed that `lid' fields definition (keyword.c:125) seems to be incorrect:
	LVAR("lid", "LID", 0, l_lid, ULONG, "d")
the 6th argument (printf format) is %d for an integer, but the associated type
is set to ULONG. On 64 bits system, we are currently mixing 32 and 64 bits
types.

I checked that `l_lid' field is of type `lwpid_t', which defined as `int32_t'.

njoly@lanfeust [tmp/ps]> grep l_lid /usr/include/sys/lwp.h 
      lwpid_t l_lid;          /* LWP identifier; local to process. */
njoly@lanfeust [tmp/ps]> grep lwpid_t /usr/include/sys/types.h 
typedef int32_t               lwpid_t;        /* LWP id */

By changing, the ULONG definition to INT32, the display looks better (just
like the i386 output).

njoly@lanfeust [tmp/ps]> ./ps.new -s
 UID  PID PPID CPU LID NLWP PRI NI VSZ  RSS WCHAN  STAT TT    TIME COMMAND
1000 2535 3486   0   1    1  18  0 220 2116 pause  I    p1 0:00.55 -zsh 
1000 2801 2535   0   1    1   2  0 240 1224 poll   S    p1 0:17.90 top -s 1 
1000 1619 1854   0   1    1  18  0 224 2156 pause  I    p2 0:00.01 -zsh 
1000 2851 1619   0   1    1   2  0 104  704 kqread I    p2 0:00.00 tail -f /var
1000 2164 2981   0   1    1   3  0 304 2244 ttyin  I    p3 0:00.07 -zsh 
1000 3746 4408   0   1    1  18  0 228 2176 pause  S    p4 0:00.03 -zsh 
1000 5302 3746   0   1    1  28  0  92  780 -      R    p4 0:00.00 ./ps.new -s 
1000 2209 1835   0   1    1  18  0 304 2232 pause  I    p5 0:00.02 -zsh 
1000 3762 2209   6   1    1  10  0 208 1040 wait   I    p5 0:00.01 /bin/sh /usr
1000 4986 3762   0   1    1   3  0 796 1788 ttyin  S    p5 0:00.11 vi /tmp/p.00

> How-To-Repeat:
Try to run `ps -s' or `ps -o lid' on a 64 bit platform.
> Fix:

Index: bin/ps/keyword.c
===================================================================
RCS file: /cvsroot/src/bin/ps/keyword.c,v
retrieving revision 1.40
diff -u -r1.40 keyword.c
--- bin/ps/keyword.c	27 Mar 2004 14:52:36 -0000	1.40
+++ bin/ps/keyword.c	26 Jul 2004 23:17:54 -0000
@@ -122,7 +122,7 @@
 	PVAR("jobc", "JOBC", 0, p_jobc, SHORT, "d"),
 	PVAR("ktrace", "KTRACE", 0, p_traceflag, INT, "x"),
 /*XXX*/	PVAR("ktracep", "KTRACEP", 0, p_tracep, KPTR, PRIx64),
-	LVAR("lid", "LID", 0, l_lid, ULONG, "d"),
+	LVAR("lid", "LID", 0, l_lid, INT32, "d"),
 	{"lim", "LIM", 0, maxrss},
 	{"login", "LOGIN", LJUST, logname},
 	{"logname", "login", ALIAS},
> Release-Note:
> Audit-Trail:
> Unformatted:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic