bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How does one use Valgrind with ncurses?


From: Thomas Dickey
Subject: Re: How does one use Valgrind with ncurses?
Date: Sat, 01 Dec 2007 12:10:29 -0500
User-agent: Mutt/1.5.17 (2007-11-01)

On Tue, Nov 27, 2007 at 10:23:37PM -0500, Steve Litt wrote:
> Hi all,
> 
> I'm building a filepicker with ncurses and c (gcc), using Valgrind to find 
> memory leaks. As mentioned here:
> 
> http://osdir.com/ml/lib.ncurses.bugs/2006-12/msg00043.html
> 
> initscr() allocates memory that isn't freed until after the program 
> terminates. I'm finding leaks with memory allocated in initscr(), 
> set_menu_mark(),  keypad(), new_menu(), mvwprintw(), and  new_item(), as well 
> as code that I've written myself (I think). This same URL:
> 
> http://osdir.com/ml/lib.ncurses.bugs/2006-12/msg00043.html
> 
> says I can rebuild nCurses with ./configure --disable-leaks. Is there another 
> way? I can't imagine what parts of my Linux distro (Mandriva 2007) depend on 
> ncurses, and I'd rather not mess with the installed ncurses if I can avoid 
> it.

Well yes, I can understand that - but it's also possible to install
copies of ncurses in different locations.  For example, in my weekly
builds, I'm installing a new version in /usr/lib (or /lib), as well
as in /usr/local/ncurses (static libraries with debugging info),
in /usr/local/ncurses6 (ncurses 6 ABI libraries).  The ncurses*config
scripts that get installed tell my other configure scripts where to
actually find the libraries.

I used to _not_ reinstall the system libraries, because I wanted to
observe bugs in their original state, but aside from some occasional
quibbles regarding package-updates reverting tic/infocmp interfaces
to an older version, it's been more useful to test current-ncurses
everywhere...
 
> If I rebuild ncurses with ./configure --disable-leaks, is there anything else 
> I need to do in order to be guaranteed that any leaks found by Valgrind are 
> not due to the ncurses libraries?

The application should also call the _nc_free_and_exit() function to
get ncurses to cleanup its use of memory.  Without that, the --disable-leaks
will only get it to free up some memory that's retained to improve performance.

That entrypoint of course is generally not in whatever package I may
automatically update to - but since I'm only using it when doing valgrind
testing on throwaway executables, it's not a big problem.

-- 
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]