--- Begin Message ---
Package: ncurses
Version: 5.9+20140913-1
The attached program does newterm() multiple times, depending on how it
is invoked, tearing down the screen with delscreen() each time.
There is one leak per invocation of newterm(), a malloc in
_nc_setupscreen.
When linked against libncursesw instead of libncurses, there is an extra
leak for every newterm() in _nc_init_wacs() (except for the first
invocation of newterm(), which appears to actually get cleaned up
properly).
It's possible that we think these links are no big deal, and that any
program using libncurses won't care. In that case, please supply
a suppression file for valgrind to avoid extra noise for people
debugging ncurses programs.
Background:
I built the attached source twice, (against libncurses and libncursesw)
like this:
-------------------
#!/usr/bin/make -f
ncurses: ncurses.c
gcc -g --pedantic -Wall -lncurses -o $@ $<
ncursesw: ncurses.c
gcc -g --pedantic -Wall -lncursesw -o $@ $<
-------------------
here are the valgrind comparisons with the different runs (note the
Command: on each comparison):
--- /dev/fd/63 2015-04-20 10:15:44.427927773 -0300
+++ /dev/fd/62 2015-04-20 10:15:44.427927773 -0300
@@ -1,15 +1,28 @@
Memcheck, a memory error detector
Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
- Command: ./ncurses 0 /dev/pts/10
+ Command: ./ncurses 1 /dev/pts/10
Parent PID: 13345
HEAP SUMMARY:
- in use at exit: 0 bytes in 0 blocks
- total heap usage: 0 allocs, 0 frees, 0 bytes allocated
+ in use at exit: 2,418 bytes in 2 blocks
+ total heap usage: 103 allocs, 101 frees, 63,155 bytes allocated
- All heap blocks were freed -- no leaks are possible
+ 2,408 bytes in 1 blocks are definitely lost in loss record 2 of 2
+ at 0x4C28C20: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
+ by 0x4E48A64: _nc_setupscreen (in /lib/x86_64-linux-gnu/libncurses.so.5.9)
+ by 0x4E45E6D: newterm (in /lib/x86_64-linux-gnu/libncurses.so.5.9)
+ by 0x400810: main (ncurses.c:15)
+
+ LEAK SUMMARY:
+ definitely lost: 2,408 bytes in 1 blocks
+ indirectly lost: 0 bytes in 0 blocks
+ possibly lost: 0 bytes in 0 blocks
+ still reachable: 10 bytes in 1 blocks
+ suppressed: 0 bytes in 0 blocks
+ Reachable blocks (those to which a pointer was found) are not shown.
+ To see them, rerun with: --leak-check=full --show-leak-kinds=all
For counts of detected and suppressed errors, rerun with: -v
- ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+ ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
--- /dev/fd/63 2015-04-20 10:15:44.435927809 -0300
+++ /dev/fd/62 2015-04-20 10:15:44.435927809 -0300
@@ -1,25 +1,25 @@
Memcheck, a memory error detector
Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
- Command: ./ncurses 1 /dev/pts/10
+ Command: ./ncurses 2 /dev/pts/10
Parent PID: 13345
HEAP SUMMARY:
- in use at exit: 2,418 bytes in 2 blocks
- total heap usage: 103 allocs, 101 frees, 63,155 bytes allocated
+ in use at exit: 4,965 bytes in 5 blocks
+ total heap usage: 204 allocs, 199 frees, 125,305 bytes allocated
- 2,408 bytes in 1 blocks are definitely lost in loss record 2 of 2
+ 4,816 bytes in 2 blocks are definitely lost in loss record 4 of 4
at 0x4C28C20: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E48A64: _nc_setupscreen (in /lib/x86_64-linux-gnu/libncurses.so.5.9)
by 0x4E45E6D: newterm (in /lib/x86_64-linux-gnu/libncurses.so.5.9)
by 0x400810: main (ncurses.c:15)
LEAK SUMMARY:
- definitely lost: 2,408 bytes in 1 blocks
+ definitely lost: 4,816 bytes in 2 blocks
indirectly lost: 0 bytes in 0 blocks
possibly lost: 0 bytes in 0 blocks
- still reachable: 10 bytes in 1 blocks
+ still reachable: 149 bytes in 3 blocks
suppressed: 0 bytes in 0 blocks
Reachable blocks (those to which a pointer was found) are not shown.
To see them, rerun with: --leak-check=full --show-leak-kinds=all
--- /dev/fd/63 2015-04-20 10:22:32.713789856 -0300
+++ /dev/fd/62 2015-04-20 10:22:32.713789856 -0300
@@ -1,25 +1,25 @@
Memcheck, a memory error detector
Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
- Command: ./ncurses 1 /dev/pts/10
+ Command: ./ncursesw 1 /dev/pts/10
Parent PID: 13345
HEAP SUMMARY:
- in use at exit: 2,418 bytes in 2 blocks
- total heap usage: 103 allocs, 101 frees, 63,155 bytes allocated
+ in use at exit: 6,653 bytes in 5 blocks
+ total heap usage: 105 allocs, 100 frees, 217,621 bytes allocated
- 2,408 bytes in 1 blocks are definitely lost in loss record 2 of 2
+ 2,408 bytes in 1 blocks are definitely lost in loss record 4 of 5
at 0x4C28C20: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
- by 0x4E48A64: _nc_setupscreen (in /lib/x86_64-linux-gnu/libncurses.so.5.9)
- by 0x4E45E6D: newterm (in /lib/x86_64-linux-gnu/libncurses.so.5.9)
- by 0x400810: main (ncurses.c:15)
+ by 0x4E4CB54: _nc_setupscreen (in /lib/x86_64-linux-gnu/libncursesw.so.5.9)
+ by 0x4E498CD: newterm (in /lib/x86_64-linux-gnu/libncursesw.so.5.9)
+ by 0x400820: main (ncurses.c:15)
LEAK SUMMARY:
definitely lost: 2,408 bytes in 1 blocks
indirectly lost: 0 bytes in 0 blocks
possibly lost: 0 bytes in 0 blocks
- still reachable: 10 bytes in 1 blocks
+ still reachable: 4,245 bytes in 4 blocks
suppressed: 0 bytes in 0 blocks
Reachable blocks (those to which a pointer was found) are not shown.
To see them, rerun with: --leak-check=full --show-leak-kinds=all
--- /dev/fd/63 2015-04-20 10:15:44.439927827 -0300
+++ /dev/fd/62 2015-04-20 10:15:44.439927827 -0300
@@ -1,28 +1,35 @@
Memcheck, a memory error detector
Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
- Command: ./ncurses 2 /dev/pts/10
+ Command: ./ncursesw 2 /dev/pts/10
Parent PID: 13345
HEAP SUMMARY:
- in use at exit: 4,965 bytes in 5 blocks
- total heap usage: 204 allocs, 199 frees, 125,305 bytes allocated
+ in use at exit: 13,157 bytes in 7 blocks
+ total heap usage: 206 allocs, 199 frees, 434,217 bytes allocated
- 4,816 bytes in 2 blocks are definitely lost in loss record 4 of 4
+ 4,096 bytes in 1 blocks are definitely lost in loss record 5 of 6
+ at 0x4C2AD10: calloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
+ by 0x4E6169E: _nc_init_wacs (in /lib/x86_64-linux-gnu/libncursesw.so.5.9)
+ by 0x4E4CE3A: _nc_setupscreen (in /lib/x86_64-linux-gnu/libncursesw.so.5.9)
+ by 0x4E498CD: newterm (in /lib/x86_64-linux-gnu/libncursesw.so.5.9)
+ by 0x400820: main (ncurses.c:15)
+
+ 4,816 bytes in 2 blocks are definitely lost in loss record 6 of 6
at 0x4C28C20: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
- by 0x4E48A64: _nc_setupscreen (in /lib/x86_64-linux-gnu/libncurses.so.5.9)
- by 0x4E45E6D: newterm (in /lib/x86_64-linux-gnu/libncurses.so.5.9)
- by 0x400810: main (ncurses.c:15)
+ by 0x4E4CB54: _nc_setupscreen (in /lib/x86_64-linux-gnu/libncursesw.so.5.9)
+ by 0x4E498CD: newterm (in /lib/x86_64-linux-gnu/libncursesw.so.5.9)
+ by 0x400820: main (ncurses.c:15)
LEAK SUMMARY:
- definitely lost: 4,816 bytes in 2 blocks
+ definitely lost: 8,912 bytes in 3 blocks
indirectly lost: 0 bytes in 0 blocks
possibly lost: 0 bytes in 0 blocks
- still reachable: 149 bytes in 3 blocks
+ still reachable: 4,245 bytes in 4 blocks
suppressed: 0 bytes in 0 blocks
Reachable blocks (those to which a pointer was found) are not shown.
To see them, rerun with: --leak-check=full --show-leak-kinds=all
For counts of detected and suppressed errors, rerun with: -v
- ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
+ ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
Thanks for maintaining curses in debian!
--dkg
#include <curses.h>
#include <stdlib.h>
#include <stdio.h>
int
main(int argc, const char* argv[])
{
SCREEN* screen;
int z = atoi(argv[1]);
int j;
FILE *i, *o;
for (j = 0; j < z; j++) {
i = fopen(argv[2], "r");
o = fopen(argv[2], "w");
screen = newterm(NULL, o, i);
delscreen(screen);
fclose(i);
fclose(o);
}
return 0;
}
--- End Message ---