bug-ncurses
[Top][All Lists]
Advanced

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

Re: Memleaks?


From: Thomas Dickey
Subject: Re: Memleaks?
Date: Fri, 21 Jun 2024 16:54:14 -0400

On Fri, Jun 21, 2024 at 12:25:58PM +0200, Michael Vetter wrote:
> I ran valgrind on my program and saw a couple of memleaks. I suspected that
> I'm using ncurses wrong but couldn't find the cause.
> 
> I then went on to download ncurses 6.3, compiled it and ran: `valgrind
> --leak-check=full ./test/firstlast`

The options used might be relevant, but I don't see this particular one
(--with-shared --without-ada, and then adding -g to get line numbers)

see attached log

valgrind with these options

        --num-callers=10 \
        --error-limit=no \
        --show-reachable=yes \
        --leak-resolution=high \
        --track-origins=yes \
        --leak-check=yes \
        --show-reachable=yes"

Adding the --leak-check option made no difference.
  
> It interestingly showed me leaks as well.
> 
> ```
> 
> ==15006== HEAP SUMMARY:
> ==15006==     in use at exit: 111,572 bytes in 264 blocks
> ==15006==   total heap usage: 275 allocs, 11 frees, 120,214 bytes allocated
> ==15006==
> ==15006== 9 bytes in 1 blocks are possibly lost in loss record 8 of 74
> ==15006==    at 0x4845794: malloc (in
> /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==15006==    by 0x491C75D: strdup (in /usr/lib64/libc.so.6)
> ==15006==    by 0x4140F5: tparm_setup (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x416EA6: _nc_tiparm (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x406BDE: _nc_mvcur_init_sp (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x4077E7: newterm_sp (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x407A44: newterm (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x4056A0: initscr (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x402462: main (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==
> ==15006== 24 bytes in 1 blocks are possibly lost in loss record 27 of 74
> ==15006==    at 0x4845794: malloc (in
> /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==15006==    by 0x4984CA5: tsearch (in /usr/lib64/libc.so.6)
> ==15006==    by 0x414110: tparm_setup (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x416EA6: _nc_tiparm (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x406BDE: _nc_mvcur_init_sp (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x4077E7: newterm_sp (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x407A44: newterm (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x4056A0: initscr (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x402462: main (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==
> ==15006== 168 bytes in 1 blocks are possibly lost in loss record 53 of 74
> ==15006==    at 0x484CA2F: calloc (in
> /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==15006==    by 0x41406E: tparm_setup (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x416EA6: _nc_tiparm (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x406BDE: _nc_mvcur_init_sp (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x4077E7: newterm_sp (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x407A44: newterm (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x4056A0: initscr (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==    by 0x402462: main (in
> /home/michael/Downloads/browser/ncurses/ncurses-6.3/test/firstlast)
> ==15006==
> ==15006== LEAK SUMMARY:
> ==15006==    definitely lost: 0 bytes in 0 blocks
> ==15006==    indirectly lost: 0 bytes in 0 blocks
> ==15006==      possibly lost: 201 bytes in 3 blocks
> ==15006==    still reachable: 111,371 bytes in 261 blocks
> ==15006==         suppressed: 0 bytes in 0 blocks
> 
> ```
> 
> Am I using valgrind/ncurses wrong? Are there memleaks in ncurses? Any
> hints/help is appreciated :)
> 
> Best,
> 
> Michael
> 
> 

-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net

Attachment: valgrind.log.gz
Description: application/gzip

Attachment: signature.asc
Description: PGP signature


reply via email to

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