Debian Bug report logs - #493465
libncurses5: allocates memory that is never freed

version graph

Package: libncurses5; Maintainer for libncurses5 is Craig Small <[email protected]>; Source for libncurses5 is src:ncurses (PTS, buildd, popcon).

Reported by: "brian m. carlson" <[email protected]>

Date: Sat, 2 Aug 2008 19:33:04 UTC

Severity: normal

Found in version ncurses/5.6+20080713-1

Full log


Message #20 received at [email protected] (full text, mbox, reply):

Received: (at 493465) by bugs.debian.org; 3 Aug 2008 01:00:39 +0000
From [email protected] Sun Aug 03 01:00:39 2008
X-Spam-Checker-Version: SpamAssassin 3.1.4-bugs.debian.org_2005_01_02 
	(2006-07-26) on rietz.debian.org
X-Spam-Level: 
X-Spam-Status: No, score=-5.7 required=4.0 tests=BAYES_00,FORGED_RCVD_HELO,
	HAS_BUG_NUMBER,IMPRONONCABLE_1,MURPHY_WRONG_WORD2 autolearn=no 
	version=3.1.4-bugs.debian.org_2005_01_02
Return-path: <[email protected]>
Received: from mknod.org ([209.223.236.42] ident=postfix)
	by rietz.debian.org with esmtp (Exim 4.63)
	(envelope-from <[email protected]>)
	id 1KPRxf-00016z-II
	for [email protected]; Sun, 03 Aug 2008 01:00:39 +0000
Received: from crustytoothpaste.ath.cx (c-98-194-252-152.hsd1.tx.comcast.net [98.194.252.152])
	by mknod.org (Postfix) with ESMTPS id 4FFA36B0075;
	Sat,  2 Aug 2008 20:00:36 -0500 (CDT)
Received: from crustytoothpaste.ath.cx (lakeview.crustytoothpaste.ath.cx [172.16.2.249])
	(authenticated bits=0)
	by crustytoothpaste.ath.cx (8.14.3/8.14.3/Debian-5) with ESMTP id m7310M9Q019093
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO);
	Sun, 3 Aug 2008 01:00:29 GMT
Date: Sun, 3 Aug 2008 01:00:02 +0000
From: "brian m. carlson" <[email protected]>
To: Thomas Dickey <[email protected]>
Cc: [email protected]
Subject: Re: Bug#493465: libncurses5: allocates memory that is never freed
Message-ID: <[email protected]>
References: <[email protected]> <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="GID0FwUMdk1T2AWN"
Content-Disposition: inline
In-Reply-To: <[email protected]>
X-No-CC: If you CC me on this list, I will feed you to Branden Robinson.
X-Machine: Running on lakeview using GNU/Linux on x86_64 (Linux kernel
	2.6.26-1-amd64)
User-Agent: Mutt/1.5.18 (2008-05-17)
[Message part 1 (text/plain, inline)]
On Sat, Aug 02, 2008 at 07:46:49PM -0400, Thomas Dickey wrote:
> On Sat, 2 Aug 2008, brian m. carlson wrote:
>
>> Package: libncurses5
>> Version: 5.6+20080713-1
>> Severity: normal
>>
>> According to valgrind, libncurses5 allocates approximately 118k that is
>> never freed:
>
> from INSTALL:
>
>     --disable-leaks
>         For testing, compile-in code that frees memory that normally would not
>         be freed, to simplify analysis of memory-leaks.
>
>         Any implementation of curses must not free the memory associated with
>         a screen, since (even after calling endwin()), it must be available
>         for use in the next call to refresh().  There are also chunks of
>         memory held for performance reasons.  That makes it hard to analyze
>         curses applications for memory leaks.  To work around this, build
>         a debugging version of the ncurses library which frees those chunks
>         which it can, and provides the _nc_free_and_exit() function to free
>         the remainder on exit.  The ncurses utility and test programs use this
>         feature, e.g., via the ExitProgram() macro.

This isn't really a solution unless the libncurses5 package is built
with it.  It's great that you considered this problem and built in an
option to fix it, but it's not compiled into the Debian package, and so
the Debian package leaks memory.  Shared libraries aren't supposed to do
that.

I personally don't believe refresh is required to work after a
delwin(stdscr), since

  Calling delwin deletes the named window, freeing all memory associated
  with it....

except that it doesn't free all the memory associated with it.  It does
free *some* of it, but not all.  I don't see any possible objection to
freeing all the related memory in this case, since calling refresh would
invoke undefined behavior.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 713 440 7475 | http://crustytoothpaste.ath.cx/~bmc | My opinion only
troff on top of XML: http://crustytoothpaste.ath.cx/~bmc/code/thwack
OpenPGP: RSA v4 4096b 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
[signature.asc (application/pgp-signature, inline)]

Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Fri May 16 05:11:32 2025; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.