Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Jul 2017 18:18:59 +0000
From:      Glen Barber <gjb@FreeBSD.org>
To:        Peter <pmc@citylink.dinoex.sub.org>
Cc:        freebsd-stable@FreeBSD.ORG, Allan Jude <allanjude@freebsd.org>
Subject:   Re: 11.1-RELEASE: new line containing garbage added to "top"
Message-ID:  <20170728181859.GI32551@FreeBSD.org>
In-Reply-To: <olfqrk$2eou$1@oper.dinoex.de>
References:  <olfdv2$17v5$1@oper.dinoex.de> <20170728160436.GE32551@FreeBSD.org> <olfqrk$2eou$1@oper.dinoex.de>

next in thread | previous in thread | raw e-mail | index | archive | help

--2FkSFaIQeDFoAt0B
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Jul 28, 2017 at 07:04:51PM +0200, Peter wrote:
> Glen Barber wrote:
> > On Fri, Jul 28, 2017 at 03:24:50PM +0200, Peter wrote:
> > > After upgrading to 11.1-RELEASE, a new line appears in the output of =
"top"
> > > which contains rubbish:
> > >=20
> > > > last pid: 10789;  load averages:  5.75,  5.19,  3.89    up 0+00:34:=
46 03:23:51
> > > > 1030 processes:9 running, 1004 sleeping, 17 waiting
> > > > CPU 0: 16.0% user,  0.0% nice, 78.7% system,  4.9% interrupt,  0.4%=
 idle
> > > > CPU 1:  8.0% user,  0.0% nice, 82.5% system,  9.1% interrupt,  0.4%=
 idle
> > > > Mem: 218M Active, 34M Inact, 105M Laundry, 600M Wired, 18M Buf, 34M=
 Free
> > > > ARC: 324M Total, 54M MFU, 129M MRU, 2970K Anon, 13M Header, 125M Ot=
her
> > > >      136=BF176M Compress185 194M Uncompressed361.94:1 Ratio
> > > > Swap: 2441M Total, 277M Used, 2164M Free, 11% Inuse
> > >=20
> > > >   PID USERNAME   PRI NICE   SIZE    RES STATE   C   TIME    WCPU CO=
MMAND
> > > ..
> > >=20
> > >=20
> > > That looks funny. But I dont like it.
> > >=20
> >=20
> > It appears to be fixed in 11-STABLE (r321419).
> >=20
> > Glen
> >=20
>=20
> I don't think so. At least there is nothing in the commitlog. r318449 is =
the
> last commit in 11-STABLE for the respective file; and thats before the
> 11.1-RELEASE branch.
>=20

See r321419.

> The error is in the screen-formatting in "top", and that error was already
> present back in 1997 (and probably earlier), and it is also present in HE=
AD.
>=20
> What "top" does is basically this:
>=20
> > char *string =3D some_buffer_to_print;
> > printf("%.5s", &string[-4]);
>=20
> A negative index on a string usually yields a nullified area. (Except if
> otherwise *eg*) Thats why we usually don't see the matter - nullbytes are
> invisible on screen.
>=20
> Fix is very simple:
>=20
> Index: contrib/top/display.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- display.c   (revision 321434)
> +++ display.c   (working copy)
> @@ -1310,7 +1310,7 @@
>         cursor_on_line =3D Yes;
>         putchar(ch);
>         *old =3D ch;
> -       lastcol =3D 1;
> +       lastcol++;
>      }
>      old++;
>=20
>=20
> ---------------------------------------------------------
> Then, since I was at it, I decided to beautify the proc display as well, =
as
> I usually see >1000 procs:
>=20
>=20
> --- display.c   (revision 321434)
> +++ display.c   (working copy)
> @@ -100,7 +100,7 @@
>  int  y_loadave =3D       0;
>  int  x_procstate =3D     0;
>  int  y_procstate =3D     1;
> -int  x_brkdn =3D         15;
> +int  x_brkdn =3D         16;
>  int  y_brkdn =3D         1;
>  int  x_mem =3D           5;
>  int  y_mem =3D           3;
> @@ -373,9 +373,9 @@
>      printf("%d processes:", total);
>      ltotal =3D total;
>=20
> -    /* put out enough spaces to get to column 15 */
> +    /* put out enough spaces to get to column 16 */
>      i =3D digits(total);
> -    while (i++ < 4)
> +    while (i++ < 5)
>      {
>         putchar(' ');
>      }
>=20
>=20
> ----------------------------------------------------------------
> Then, concerning the complaint about the empty line (bug #220996), I
> couldn't really reproduce this. But it seems that specifically this issue
> was already fixed in HEAD by this one here:
> https://reviews.freebsd.org/D11693
>=20
> ----------------------------------------------------------------
> Now, can anybody make the above snippets appear in HEAD and 11-STABLE?
>=20

I've CC'd allanjude, who has touched some of these in the past.

Glen


--2FkSFaIQeDFoAt0B
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIyBAEBCAAdFiEEjRJAPC5sqwhs9k2jAxRYpUeP4pMFAll7gA4ACgkQAxRYpUeP
4pN8SA/4hzGvoe1LP/imv3boiJyIbcWcnV00+TTAgc2oXJGIL1q8egAlkzrBuiM1
xPMUM9Im7xV2/w0HXYB6obIQbDB2r8B88SV+aWCodblzShDj23DOxyvKCSi5V3nQ
yH4E5AMq8RHEDpCD09Po5/AiZkW0o70hNHGnhb6Gf5yIrTTgP9zJ2ejV+BCmSOE4
k2PQG1N4kY0CPwqFfB9ECbCIt4O51N3XxDnnWQxutXV8e6mvp10w0zKL5ugVHOkE
n77Rxnr4kDaTbB5lyXofRfq3h69/G/A80L9t1jqwAx01+ADioo4eSth68OJgpvlM
BIuplMGcSYfo+JnU1orHCpU/V8xrbBw4hlfU7aVSQkJOjAWg9iGyn3W2QvNpR2cs
7/nBml54iq+quGxhTsrxPfZkU4nSseuS8vN96DwPRFEPSLX8FnPSUs2boJ0XQ5d/
WcUw+sD7jDwqCbxByojTLnrjWdqkN3Ofp0mHno3pRmn7mJdFl1nTU/CDVLzBQLiz
NF37oONxg875PgfT9BB5AVpiWqyUFqD8oVDCGyOjxoEa/9IZBcHusJm6zxB8DSoD
DOjGALj+4LBLuip5Oer8SDYMmQs9/myqTa1bBIEYq8ZnCl98MvpumXVgscZuiPjG
J13qNpcOxdsApYfO/+udWjNnOvuXeeoYyeEyLsXnlfZdhEkTsw==
=IJHr
-----END PGP SIGNATURE-----

--2FkSFaIQeDFoAt0B--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170728181859.GI32551>