| Summary: | top: can't allocate sufficient memory | ||
|---|---|---|---|
| Product: | Base System | Reporter: | lan <lan> |
| Component: | bin | Assignee: | dwmalone |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.1-STABLE | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
lan
2000-09-06 09:00:04 UTC
On Wed, 06 Sep 2000 00:50:48 MST, lan@kru.ru wrote: > >Number: 21075 > >Category: bin > >Synopsis: top: can't allocate sufficient memory This happens because top needs 7 lines for headers. display_resize() calculates that the number of lines available is -1 and returns this value. As it happens, display_init() interprets this -1 return value as a memory allocation error. I'm downloading top-3.5beta9 to see whether this problem is fixed in that version. As a work-around, you can use top's -b (batch mode) option. Ciao, Sheldon. The following patch teaches top(1) to exit if it has fewer than
Header_lines available for display. I don't think there's any more
sensible behaviour; automatically turning on batch mode in this
situation doesn't seem smart to me.
Although both affected files are off the vendor branch, I don't see this
as a critical bug and would prefer to submit this patch to the top
maintainers. Once they have an "officially adopted" patch for us, we'll
commit that.
Ciao,
Sheldon.
Index: display.c
===================================================================
RCS file: /home/ncvs/src/contrib/top/display.c,v
retrieving revision 1.4
diff -u -d -r1.4 display.c
--- display.c 1999/01/09 20:20:33 1.4
+++ display.c 2000/09/06 10:49:33
@@ -99,6 +99,8 @@
/* calculate the current dimensions */
/* if operating in "dumb" mode, we only need one line */
lines = smart_terminal ? screen_length - Header_lines : 1;
+ if (lines < 0)
+ return(-2);
/* we don't want more than MAX_COLS columns, since the machine-dependent
modules make static allocations based on MAX_COLS and we don't want
Index: top.c
===================================================================
RCS file: /home/ncvs/src/contrib/top/top.c,v
retrieving revision 1.4
diff -u -d -r1.4 top.c
--- top.c 1999/01/09 20:20:34 1.4
+++ top.c 2000/09/06 10:54:32
@@ -439,6 +439,11 @@
fprintf(stderr, "%s: can't allocate sufficient memory\n", myname);
exit(4);
}
+ if (max_topn == -2) {
+ fprintf(stderr, "%s: this terminal has fewer than %d lines\n",
+ myname, Header_lines);
+ exit(1);
+ }
/* print warning if user requested more processes than we can display */
if (topn > max_topn)
Responsible Changed From-To: freebsd-bugs->sheldonh I'll manage this one. State Changed From-To: open->feedback I have contacted the author (wnl@groupsys.com) and am now waiting for an "officially adopted" patch. Responsible Changed From-To: sheldonh->dwmalone David kindly volunteered to look at this one for me. ;-) State Changed From-To: feedback->closed Now resolved in -current and -stable. |