The smatch error --------------
top.c +1414 calibrate_fields(78) error: buffer overflow 'Fieldstab' 39 <= 39
The code -----------------------
if (P_MAXPFLGS < f) { w->endpflg = i; continue; }
The background -----------------
The enum P_MAXPFLGS is strictly a fencepost and can *never* appear in
the arrays pflgsall or procflgs. Thus it (39th element) cannot be used
in referencing Fieldstab.
However, two enums of higher value (X_XON=40 and X_XOF=41) *can* appear
in those arrays. But the test against the fencepost ensures that those
two enums are *never* used in referencing Fieldstab.
When the analyzer sees the conditional using '<' and not '<='
it reports a false positive.
The source was changed to accommodate the tool's deficiency
With forest view mode under procps-ng-3.3.0, top would catch
a SEGV and exit. The problem was thought to be related to
some linux version 3 anamoly.
In procps-ng-3.3.1, top was protected from abnormal exit and
would display the offending processes with the special orphan
notation '?', instead of the usual artwork.
As it turns out, the problem wasn't with linux and could
surface under a 2.6.xx kernel, The cause was an occasional
abnormal ordering of tid/tgid/ppid which went unresolved
due to a progressive proc table scan in the recursive
function forest_add().
By default the proc table scan now restarts at the beginning.
However, a #define TREE_ONEPASS is provided should one wish
to restore the 3.3.1 behavior with its reduced overhead.
An anomaly would surface whenever the sort column was
made non-display under fields management.
The scroll message would report incorrect x coordinates
and the 'x' toggle would produce an unintentional
horizontal scroll.
This patch forces column highlighting off whenever field
changes are made (as is done for horizontal scrolling).
It also inactivates the 'x' toggle whenever the sort
column is not visible.
This bug has yet to be reported.
In the procs_refresh() function:
. the proctable scan was simplified
. memory allocation is now much more efficient
. window ppts will usually not now need xrealloc
Now that the library allows for customizing the response to
memory allocation errors, it is no longer necessary for top
to provide its own.
This library extension was necessary since top modifies the
termios structure and there would otherwise be no way to
restore the users tty.
When PROC_FILLARG was used (invoking file2strvec)
command lines contained no trailing space.
When PROC_EDITCMDLCVT was used (invoking read_unvectored)
command lines contained a trailing space.
Now both routes to a cmdline act the same -- no trailing space.
The CodingStyle document suggests programs should allow for
cmdlines of at least 128k. Only the ps program can display
such a cmdline, and only with multiple -w switches.
The library function file2strvec can essentially return
a cmdline of unlimited length. However, the library function
fill_cmdline_cvt used an arbitrary upper limit of 2048 for
buffers automatically allocated on the stack.
This patch raises the fill_cmdline_cvt upper limit to 128k via
dymaically acquired utility buffers ensured by the openproc
function.
It also makes indentation consistent in the openproc function.
There were numerous library memory allocation inconsistencies.
Some were checked for failure and others were not.
All library source modules were modified to utilize the alloc.h
memory rouines which are consistent in dealing with errors.
A callback provision in the form of xalloc_err_handler
(of type message_fn) was added to the alloc module.
This change allowed a program like top, who alters the
termios structure, to override the default fprint(stderr...)
behavior in the event of an error.
The new function xstrdup was also added for symmetry.
Makefile.am testsuite needed to explicitly state the files because while
everything else works, make distcheck fails.
NEWS got updated with the Debian bug number for pgrep -u
There is a race condition between expect script consuming the output
from slabtop. There were a sequences of lines that looked like
^\d+ ... \s*
with the last \s* consuming the first space on the start of the line.
However if the line takes too long to print, then expect stops there and
the space at the start of the subsquent line does not match.
The solution is a \s* at the start ofthe line.
Fix to ./autogen.sh error bellow.
/usr/share/automake-1.11/am/dejagnu.am: DEJATOOL was already defined in condition LINUX, which is included in condition TRUE ...
testsuite/Makefile.am:6: ... `DEJATOOL' previously defined here
Reference: http://www.freelists.org/post/procps/procpsng-331-nearly-there,5
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Makefile will now only test for Linux systems, a work around in the
makefile due to some silly redefine restrictions.
uptime and w now won't error due to being one user logged in, thanks to
Sami for the patch
kill processes by pid test commented out due to false negatives
pwdx process 1 check also commented out due to false negatives
procps works well on Linux, on other arches there are some strange
differences due to their emulation of procfs which is not 100%
Disabling checks for non-linux until that can be sorted out.
Using ncurses initscr/endwin clears the screen for xterm/etc it
now prints raw text using printf
Bug-Debian: http://bugs.debian.org/503089
Author: Craig Small <csmall@debian.org>
Things like lexgrog and whatis and apropos need to look a the line in
the NAME section in the manpage. There used to be a macro there which
they don't understand.
lexgrog top.1
top.1: parse failed
configure.ac now set to 3.3.1
vmstat -p has not worked for a long time, this applies Debian patch
vmstat_part_format, the details:
Author: Daniel Novotny
Description: The contents of /proc/diskstats have changed since 2.6.25
Changed PATH_MAX to 32 because its missing on hurd
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=485243
Bug-Debian: http://bugs.debian.org/588677
Last-Update: 2010-11-17
Notice that contents of file library.map file are almost certainly
wrong as it is making everything exported.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
. 3 pgms require non-wide <curses.h> or <ncurses.h>
This patch represents the tests for a minimal environment
consistent with current ncurses needs.
It should allow a successful configure and build
. 1 program uses curses (top)
. 2 programs use ncurses (slabtop, watch)
. all 3 include non-wide <curses.h> or <ncurses.h>
. those 3 do not currently need wide support
. but anticipating nls, we link against libncursesw
This patch ensures an environment consistent with current
and future ncurses needs.