From kstailey@bsdlab.tf-md.net  Fri Dec 13 05:55:11 2002
Return-Path: <kstailey@bsdlab.tf-md.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 25C0637B401
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Dec 2002 05:55:11 -0800 (PST)
Received: from bsdlab.tf-md.net (64-93-1-35.client.dsl.net [64.93.1.35])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4F22743ED1
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Dec 2002 05:55:10 -0800 (PST)
	(envelope-from kstailey@bsdlab.tf-md.net)
Received: from bsdlab.tf-md.net (localhost.tf-md.net [127.0.0.1])
	by bsdlab.tf-md.net (8.12.6/8.12.6) with ESMTP id gBDDrC7h017362
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Dec 2002 08:53:13 -0500 (EST)
	(envelope-from kstailey@bsdlab.tf-md.net)
Received: (from kstailey@localhost)
	by bsdlab.tf-md.net (8.12.6/8.12.6/Submit) id gBDDrCRa017361;
	Fri, 13 Dec 2002 08:53:12 -0500 (EST)
Message-Id: <200212131353.gBDDrCRa017361@bsdlab.tf-md.net>
Date: Fri, 13 Dec 2002 08:53:12 -0500 (EST)
From: Ken Stailey <kstailey@bsdlab.tf-md.net>
Reply-To: Ken Stailey <kstailey@bsdlab.tf-md.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: ps(1) re an sl fields are broken
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         46232
>Category:       bin
>Synopsis:       ps(1) re an sl fields are broken
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    tjr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 13 06:00:13 PST 2002
>Closed-Date:    Sat Apr 12 03:42:39 PDT 2003
>Last-Modified:  Sat Apr 12 03:42:39 PDT 2003
>Originator:     Ken Stailey
>Release:        FreeBSD 5.0-RC i386
>Organization:
Thomson Financial
>Environment:
System: FreeBSD bsdlab.tf-md.net 5.0-RC FreeBSD 5.0-RC #0: Wed Dec 11 07:53:15 EST 2002 kstailey@bsdlab.tf-md.net:/usr/obj/usr/src/sys/BSDLAB i386


>Description:

4.3BSD's ps(1) RE and SL fields could not count higher than 99 on purpose.
4.4BSD's ps(1) RE and SL fields are not supposed to count higher than 127
on purpose but the CSRG did not have time to fix this if I look at
static char sccsid[] = "@(#)keyword.c   8.5 (Berkeley) 4/2/94";
on my _CSRG Archives_ CD-ROM set.

I submitted patches into NetBSD and somebody wrote improved versions.
OpenBSD forked with those patches built-in.
Now only FreeBSD is broken.

>How-To-Repeat:

ps vax

(system must be booted for more than 127 seconds)

>Fix:

begin 644 ps.patch.current.gz
M'XL("+OD^3T``W!S+G!A=&-H+F-U<G)E;G0`O5;;<N)&$'V6OJ*+5+P2"$L"
MC!RYO/'&B[W$!+NXO.2%DJ61F2`D:C0"DXW_/3TC+O("6:BD0E&,---]^C+=
M?>C=]B&D$7'!'"=38L;^/#53YIO/-#9GJ3DART7"@G/?F*N,<$;)G,8OP'!)
M:1*#?7YQJ08T#*&:096)5]CHJ-5J=?NFU"RK9MJ666N`9;GXO7`4J5^I5';$
M\%L'N^8VFJY=4V]NH&HW:H8#E7RYN5%!^5J:S6A0,J#T]-3^C&MWV.D88!DP
MF7ML_8I'G5;7@(?'NSMM0D="1S=@V.X.#`11\/SNMP&JO1DY)J,2LM<N(N+N
M^JTN-VZ_?.IMSE&UBJJ,",U>ZY`K]:T7Z8+3*5G[`24,0ZWL@VAW[^R:<Q(.
M!K4.AKWD">K='T[0\)L$"1U=HN28PT*"Y$4T+^1%R$5>Q$JP]%K:IC&E+U,O
MG0CCOW0>;Q]:!^U?%J+)E8K6-Z`BP6DD\/J=8Q(<S?9G>`?C>QG>!U1(<<H]
MQB7DX%-O4`BS\^NP/_AKV&]AG4@A$JR/G&]+:`W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19:03:42 -0500 (EST)

 More evidence:
 
 kstailey@bsdlab$ man ps | grep infinity
      re         core residency time (in seconds; 127 = infinity)
      sl         sleep time (in seconds; 127 = infinity)
 kstailey@bsdlab$ 
 

From: Ken Stailey <kstailey@bsdlab.tf-md.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/46232: ps(1) re an sl fields are broken
Date: Tue, 28 Jan 2003 19:08:46 -0500 (EST)

 Yet more evidence:
 
 /*
  * Copyright (c) 1980 Regents of the University of California.
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  */
 
 #ifndef lint
 char copyright[] =
 "@(#) Copyright (c) 1980 Regents of the University of California.\n\
  All rights reserved.\n";
 #endif not lint
 
 #ifndef lint
 static char sccsid[] = "@(#)ps.c        5.15 (Berkeley) 4/13/88";
 #endif not lint
 
 [...skip ahead...]
 
  =
 " SIZE  PID TT STAT TIME SL RE PAGEIN  SIZE   RSS   LIM TSIZ TRS %CPU %MEM"+5;
 vpr(sp)
         struct savcom *sp;
 {
         register struct vsav *vp = sp->s_un.vp;
         register struct asav *ap = sp->ap;
 
         printf("%5u ", ap->a_pid);
         ptty(ap->a_tty);
         printf(" %-2.3s", state(ap));
         ptime(ap);
         printf(" %2d %2d %6d %5d %5d",
            ap->a_slptime > 99 ? 99 : ap-> a_slptime,
            ap->a_time > 99 ? 99 : ap->a_time, vp->v_majflt,
            pgtok(ap->a_size), pgtok(ap->a_rss));
         if (ap->a_maxrss == (RLIM_INFINITY/NBPG))
                 printf("    xx");
         else
                 printf(" %5d", pgtok(ap->a_maxrss));
         printf(" %4d %3d %4.1f %4.1f",
            pgtok(ap->a_tsiz), pgtok(ap->a_txtrss), vp->v_pctcpu, pmem(ap));
 }
 
 Do you see what vpr() from pre-reno 4.3BSD is doing to the RE and SL
 fields?  It's limited them to 99 max which is analogous to the modern
 one limiting RE and SL to 127.  The man page for post-4.3BSD-reno and
 beyond says:
 
 .\" Copyright (c) 1980, 1990, 1991, 1993, 1994
 .\"     The Regents of the University of California.  All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
 .\" are met:
 .\" 1. Redistributions of source code must retain the above copyright
 .\"    notice, this list of conditions and the following disclaimer.
 .\" 2. Redistributions in binary form must reproduce the above copyright
 .\"    notice, this list of conditions and the following disclaimer in the
 .\"    documentation and/or other materials provided with the distribution.
 .\" 3. All advertising materials mentioning features or use of this software
 .\"    must display the following acknowledgement:
 .\"     This product includes software developed by the University of
 .\"     California, Berkeley and its contributors.
 .\" 4. Neither the name of the University nor the names of its contributors
 .\"    may be used to endorse or promote products derived from this software
 .\"    without specific prior written permission.
 .\"
 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)ps.1        8.3 (Berkeley) 4/18/94
 .\"
 .Dd April 18, 1994
 .Dt PS 1
 .Os BSD 4
 
 [...skip ahead...]
 
 .It re
 core residency time (in seconds; 127 = infinity)
 .It rgid
 
 [...skip ahead...]
 
 .It sl
 sleep time (in seconds; 127 = infinity)
 .It start
 
 but it was never implemented, just documented.  That's what you get
 for writing the documentation first as a specification instead of
 blindly hacking code (just kidding.)
Responsible-Changed-From-To: freebsd-bugs->tjr 
Responsible-Changed-By: tjr 
Responsible-Changed-When: Sat Apr 12 03:23:41 PDT 2003 
Responsible-Changed-Why:  
I'll handle this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=46232 
State-Changed-From-To: open->closed 
State-Changed-By: tjr 
State-Changed-When: Sat Apr 12 03:41:41 PDT 2003 
State-Changed-Why:  
Fixed in -current. I do not think it is a good idea to change the behaviour 
in -stable. Thanks for the patch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=46232 
>Unformatted:
