bug-ncurses
[Top][All Lists]
Advanced

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

Re: memory leak - tgetent - ncurses 5.6


From: Thomas Dickey
Subject: Re: memory leak - tgetent - ncurses 5.6
Date: Wed, 8 Apr 2009 07:19:52 -0400 (EDT)

On Tue, 7 Apr 2009, Maciek Borzecki wrote:

Hi,

I'm writing a small application that's using libedit, which internally
calls ncurses.
Monitoring it with valgrind, I keep observing the memory leaks coming
from tgetent as follows (see attachment for full log):

I should add this to the faq (it's in the INSTALL file in ncurses sources):

    --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.


==4683== 44 bytes in 1 blocks are still reachable in loss record 3 of 7
==4683==    at 0x4023DE2: calloc (vg_replace_malloc.c:397)
==4683==    by 0x4083456: _nc_read_termtype (in /lib/libncurses.so.5.6)
==4683==    by 0x4083CC4: _nc_read_file_entry (in /lib/libncurses.so.5.6)
==4683==    by 0x4083E65: _nc_read_entry (in /lib/libncurses.so.5.6)
==4683==    by 0x407FA92: _nc_setupterm (in /lib/libncurses.so.5.6)
==4683==    by 0x40802B7: tgetent (in /lib/libncurses.so.5.6)
==4683==    by 0x404E649: (within /usr/lib/libedit.so.2.11)
==4683==    by 0x404F0D6: el_init (in /usr/lib/libedit.so.2.11)
==4683==    by 0x8049E03: setup_el (uish.c:58)
==4683==    by 0x804A1C8: uish_init (uish.c:167)
==4683==    by 0x8049BF6: main (main.c:106)
==4683==
==4683==
==4683== 78 bytes in 1 blocks are still reachable in loss record 4 of 7
==4683==    at 0x4023DE2: calloc (vg_replace_malloc.c:397)
==4683==    by 0x40834CD: _nc_read_termtype (in /lib/libncurses.so.5.6)
==4683==    by 0x4083CC4: _nc_read_file_entry (in /lib/libncurses.so.5.6)
==4683==    by 0x4083E65: _nc_read_entry (in /lib/libncurses.so.5.6)
==4683==    by 0x407FA92: _nc_setupterm (in /lib/libncurses.so.5.6)
==4683==    by 0x40802B7: tgetent (in /lib/libncurses.so.5.6)
==4683==    by 0x404E649: (within /usr/lib/libedit.so.2.11)
==4683==    by 0x404F0D6: el_init (in /usr/lib/libedit.so.2.11)
==4683==    by 0x8049E03: setup_el (uish.c:58)
==4683==    by 0x804A1C8: uish_init (uish.c:167)
==4683==    by 0x8049BF6: main (main.c:106)
==4683==
==4683==
==4683== 172 bytes in 1 blocks are still reachable in loss record 5 of 7
==4683==    at 0x4023DE2: calloc (vg_replace_malloc.c:397)
==4683==    by 0x407FA6C: _nc_setupterm (in /lib/libncurses.so.5.6)
==4683==    by 0x40802B7: tgetent (in /lib/libncurses.so.5.6)
==4683==    by 0x404E649: (within /usr/lib/libedit.so.2.11)
==4683==    by 0x404F0D6: el_init (in /usr/lib/libedit.so.2.11)
==4683==    by 0x8049E03: setup_el (uish.c:58)
==4683==    by 0x804A1C8: uish_init (uish.c:167)
==4683==    by 0x8049BF6: main (main.c:106)
==4683==
==4683==
==4683== 565 bytes in 1 blocks are still reachable in loss record 6 of 7
==4683==    at 0x4025D2E: malloc (vg_replace_malloc.c:207)
==4683==    by 0x4083376: _nc_read_termtype (in /lib/libncurses.so.5.6)
==4683==    by 0x4083CC4: _nc_read_file_entry (in /lib/libncurses.so.5.6)
==4683==    by 0x4083E65: _nc_read_entry (in /lib/libncurses.so.5.6)
==4683==    by 0x407FA92: _nc_setupterm (in /lib/libncurses.so.5.6)
==4683==    by 0x40802B7: tgetent (in /lib/libncurses.so.5.6)
==4683==    by 0x404E649: (within /usr/lib/libedit.so.2.11)
==4683==    by 0x404F0D6: el_init (in /usr/lib/libedit.so.2.11)
==4683==    by 0x8049E03: setup_el (uish.c:58)
==4683==    by 0x804A1C8: uish_init (uish.c:167)
==4683==    by 0x8049BF6: main (main.c:106)

Digging through changelogs I noticed that memory leaks should be
'reduced' since 5.6. Is this the reduced effect that I'm seeing?
I'll try to track down this further, perhaps the problem is ubuntu
related (canonical's custom patches or whatever).
Looking into libedit's code, the buffer for tgetent is allocated
however, it seems not to be used (actually manual page states that
tgetent ignores buffer pointer).

Cheers,
maciek


--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net




reply via email to

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