From nobody@FreeBSD.ORG  Wed Sep  6 00:50:48 2000
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 1259537B43E; Wed,  6 Sep 2000 00:50:48 -0700 (PDT)
Message-Id: <20000906075048.1259537B43E@hub.freebsd.org>
Date: Wed,  6 Sep 2000 00:50:48 -0700 (PDT)
From: lan@kru.ru
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@FreeBSD.org
Subject: top: can't allocate sufficient memory
X-Send-Pr-Version: www-1.0

>Number:         21075
>Category:       bin
>Synopsis:       top: can't allocate sufficient memory
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dwmalone
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 06 01:00:04 PDT 2000
>Closed-Date:    Sun Apr 27 08:33:03 PDT 2003
>Last-Modified:  Sun Apr 27 08:33:03 PDT 2003
>Originator:     Andrey Lobov
>Release:        4.1-STABLE,  4.0-STABLE,  4.3-STABLE
>Organization:
KuzbassRazrezUgol
>Environment:
FreeBSD lan.xxx.tu 4.1-STABLE FreeBSD 4.1-STABLE #0: Sat Aug 12 11:14:35 KRAST 2000     lan@lan.xxx.ru:/usr/src/sys/compile/LAN  i386
FreeBSD paul.yyy.ru 4.0-STABLE FreeBSD 4.0-STABLE #3: Tue Jul 18 18:18:09 GMT 2000     paul@paul.yyy.ru:/usr/src/sys/compile/PAUL  i386
FreeBSD proxy.zzz.ru 3.4-STABLE FreeBSD 3.4-STABLE #1: Fri Apr 21 12:10:45 KRAST 2000     lan@proxy.zzz.ru:/usr/src/sys/compile/LAN  i386
>Description:
If to run /usr/bin/top in any Xterminal (kvt, konsole, xterm, Eterm)
and a size of the window of the terminal less or it is equal to six
strings on a vertical we receive error messages:
top: can't allocate sufficient memory.
At the greater size - without any errors.

>How-To-Repeat:
Reduce a vertical size of the window of the Xterminal up to six 
strings (lines) and start /usr/bin/top.

>Fix:


>Release-Note:
>Audit-Trail:

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: lan@kru.ru
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/21075: top: can't allocate sufficient memory 
Date: Wed, 06 Sep 2000 12:05:02 +0200

 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.
 
Responsible-Changed-From-To: freebsd-bugs->sheldonh 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Wed Sep 6 03:58:56 PDT 2000 
Responsible-Changed-Why:  
I'll manage this one. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21075 
State-Changed-From-To: open->feedback 
State-Changed-By: sheldonh 
State-Changed-When: Wed Sep 6 04:04:30 PDT 2000 
State-Changed-Why:  
I have contacted the author (wnl@groupsys.com) and am now 
waiting for an "officially adopted" patch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21075 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: lan@kru.ru
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/21075: top: can't allocate sufficient memory 
Date: Wed, 06 Sep 2000 12:57:11 +0200

 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: sheldonh->dwmalone 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Tue Dec 11 01:20:14 PST 2001 
Responsible-Changed-Why:  
David kindly volunteered to look at this one for me. ;-) 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=21075 
State-Changed-From-To: feedback->closed 
State-Changed-By: dwmalone 
State-Changed-When: Sun Apr 27 08:32:36 PDT 2003 
State-Changed-Why:  
Now resolved in -current and -stable. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21075 
>Unformatted:
