top: provide some protection against forking anomalies
This commit will eliminate a very nasty bug associated with top's forest view mode. It addresses a potential SIGSEGV/SIGABRT that was only encountered when another program (erroneously?) creates a lengthy forking loop. If the growing list of nested children is sufficiently fast such that proc_t start_time is duplicated between children then the sort upon which top relies might not produce the expected order. That, in turn, could cause the forest_adds function to initially miss some child. But that missed child would be caught by forest_create and eventually would cause our array boundary overrun. Such overrun occurs when some child of that originally *missed* child is found and a duplicate add attempted. In correcting this bug we'll also use this opportunity to prohibit a borrowed proc_t padding byte (char) from going negative. If the nesting level exceeded 127, the effect was an "unnesting" with the snprintf width then viewed as flag+width also yielding left justification. Henceforth, we'll limit nesting to 100 with subsequent children shown as " + ", not the usual " `- " prefix. References(s): https://bugzilla.redhat.com/show_bug.cgi?id=1153642 http://www.freelists.org/post/procps/Bug-in-the-forrest-view,6 Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
committed by
Jaromir Capik
parent
b0767bd391
commit
ce70017eb1
@@ -780,7 +780,7 @@ typedef struct WIN_t {
|
||||
//atic void keys_window (int ch);
|
||||
//atic void keys_xtra (int ch);
|
||||
/*------ Forest View support -------------------------------------------*/
|
||||
//atic void forest_adds (const int self, const int level);
|
||||
//atic void forest_adds (const int self, int level);
|
||||
//atic int forest_based (const proc_t **x, const proc_t **y);
|
||||
//atic void forest_create (WIN_t *q);
|
||||
//atic inline const char *forest_display (const WIN_t *q, const proc_t *p);
|
||||
|
||||
Reference in New Issue
Block a user