From jwk@stack.nl Tue Nov 18 06:55:59 2003 Return-Path: Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DCB5D16A4CE for ; Tue, 18 Nov 2003 06:55:59 -0800 (PST) Received: from hexagon.stack.nl (hexagon.stack.nl [131.155.140.144]) by mx1.FreeBSD.org (Postfix) with ESMTP id 057AA43FB1 for ; Tue, 18 Nov 2003 06:55:59 -0800 (PST) (envelope-from jwk@stack.nl) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010:2e0:81ff:fe22:51d8]) by hexagon.stack.nl (Postfix) with ESMTP id 95D96517D; Tue, 18 Nov 2003 15:55:57 +0100 (CET) Received: by turtle.stack.nl (Postfix, from userid 887) id 829D51CC71; Tue, 18 Nov 2003 15:55:57 +0100 (CET) Message-Id: <20031118145557.829D51CC71@turtle.stack.nl> Date: Tue, 18 Nov 2003 15:55:57 +0100 (CET) From: Jan Willem Knopper Reply-To: Jan Willem Knopper To: FreeBSD-gnats-submit@freebsd.org Cc: jilles@stack.nl Subject: ps -o rtprio does not work X-Send-Pr-Version: 3.113 X-GNATS-Notify: >Number: 59417 >Category: bin >Synopsis: ps -o rtprio does not work >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Nov 18 07:00:21 PST 2003 >Closed-Date: Sat Mar 27 18:16:25 PST 2004 >Last-Modified: Sat Mar 27 18:16:25 PST 2004 >Originator: Jan Willem Knopper >Release: FreeBSD 5.1-CURRENT i386 >Organization: M.C.G.V. Stack >Environment: System: FreeBSD turtle.stack.nl 5.1-CURRENT FreeBSD 5.1-CURRENT #15: Thu Oct 9 11:43:55 CEST 2003 jilles@turtle.stack.nl:/usr/obj/usr/src/sys/TURTLE i386 >Description: 'ps -o rtprio' gives junk output: for example '208:208' instead of 'normal' >How-To-Repeat: % ps -p $$ -O rtprio PID RTPRIO TT STAT TIME COMMAND 50378 208:208 pi Ss 0:00,32 -zsh (zsh) instead of jwk@turtle:/home/jwk/src/ps% ./ps -p $$ -O rtprio PID RTPRIO TT STAT TIME COMMAND 50378 normal pi Ss 0:00,33 -zsh (zsh) >Fix: patch below --- ps-print-rtprio.patch begins here --- --- /usr/src/bin/ps/print.c.orig Tue Nov 18 15:47:44 2003 +++ /usr/src/bin/ps/print.c Tue Nov 18 15:45:36 2003 @@ -655,7 +655,7 @@ unsigned class, level; v = ve->var; - lpri = (struct priority *) ((char *)k + v->off); + lpri = (struct priority *) ((char *)k->ki_p + v->off); class = lpri->pri_class; level = lpri->pri_level; switch (class) { --- ps-print-rtprio.patch ends here --- >Release-Note: >Audit-Trail: From: Bruce Evans To: Jan Willem Knopper Cc: FreeBSD-gnats-submit@FreeBSD.org, jilles@stack.nl, freebsd-gnats-submit@FreeBSD.org Subject: Re: bin/59417: ps -o rtprio does not work Date: Wed, 19 Nov 2003 09:39:33 +1100 (EST) On Tue, 18 Nov 2003, Jan Willem Knopper wrote: > >Description: > 'ps -o rtprio' gives junk output: for example '208:208' instead of > 'normal' > ... > >Fix: > patch below > > --- ps-print-rtprio.patch begins here --- > --- /usr/src/bin/ps/print.c.orig Tue Nov 18 15:47:44 2003 > +++ /usr/src/bin/ps/print.c Tue Nov 18 15:45:36 2003 > @@ -655,7 +655,7 @@ > unsigned class, level; > > v = ve->var; > - lpri = (struct priority *) ((char *)k + v->off); > + lpri = (struct priority *) ((char *)k->ki_p + v->off); > class = lpri->pri_class; > level = lpri->pri_level; > switch (class) { I use the following variant (all the casts are bogus or wrong; not just the first one; there are also formatting errors). %%% Index: print.c =================================================================== RCS file: /home/ncvs/src/bin/ps/print.c,v retrieving revision 1.83 diff -u -2 -r1.83 print.c --- print.c 13 Aug 2003 07:35:07 -0000 1.83 +++ print.c 10 Oct 2003 17:00:05 -0000 @@ -654,7 +651,7 @@ char str[8]; unsigned class, level; - + v = ve->var; - lpri = (struct priority *) ((char *)k + v->off); + lpri = &k->ki_p->ki_pri; class = lpri->pri_class; level = lpri->pri_level; %%% This seems to be the only instance with the same type as the main bug. The reason is that v->off is only needed in kvar() and rvar() since the relevant struct member cannot be used literally there (only its offset is available). Using v->off elsewhere is bogus and the above is the only other place where it used. Bruce State-Changed-From-To: open->closed State-Changed-By: gad State-Changed-When: Sat Mar 27 18:14:05 PST 2004 State-Changed-Why: A fix for this bug was committed as revision 1.84 of ps/print.c http://www.freebsd.org/cgi/query-pr.cgi?pr=59417 >Unformatted: