This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nscd/11501] New: Memory leak when invoking openpty


Valgrind reports definitely lost memory leak when I am invoking 
openpty(). This function is defined in /usr/lib/libutil.a belonging libc6-dev. I 
also download source eglibc-2.10.1, but it doesn't help to fix my problem.


My program is:
#include <unistd.h>
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <utmp.h>
#include <pty.h>

int main(int argc, char **argv)
{
         int master, slave;

         if (openpty(&master, &slave, NULL, NULL, NULL) < 0)
               return -1;

         close(master);
         close(slave);

         return 0;
}

$ valgrind --leak-check=full ./test
==25001== Memcheck, a memory error detector
==25001== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==25001== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==25001== Command: ./test
==25001==
==25001==
==25001== HEAP SUMMARY:
==25001==     in use at exit: 160 bytes in 11 blocks
==25001==   total heap usage: 67 allocs, 56 frees, 5,594 bytes allocated
==25001==
==25001== 160 (40 direct, 120 indirect) bytes in 1 blocks are definitely 
lost in loss record 11 of 11
==25001==    at 0x4024C6C: malloc (vg_replace_malloc.c:195)
==25001==    by 0x41D8323: nss_parse_service_list (nsswitch.c:622)
==25001==    by 0x41D8A68: __nss_database_lookup (nsswitch.c:164)
==25001==    by 0x4672F2B: ???
==25001==    by 0x4673A24: ???
==25001==    by 0x418F954: getgrnam_r@@GLIBC_2.1.2 (getXXbyYY_r.c:253)
==25001==    by 0x41FB2FE: __unix_grantpt (grantpt.c:138)
==25001==    by 0x41FB588: grantpt (grantpt.c:84)
==25001==    by 0x40F7021: openpty (openpty.c:102)
==25001==    by 0x804A0E4: main (test-server2.c:40)
==25001==
==25001== LEAK SUMMARY:
==25001==    definitely lost: 40 bytes in 1 blocks
==25001==    indirectly lost: 120 bytes in 10 blocks
==25001==      possibly lost: 0 bytes in 0 blocks
==25001==    still reachable: 0 bytes in 0 blocks
==25001==         suppressed: 0 bytes in 0 blocks
==25001==
==25001== For counts of detected and suppressed errors, rerun with: -v
==25001== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 25 from 8)

-- 
           Summary: Memory leak when invoking openpty
           Product: glibc
           Version: 2.10
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nscd
        AssignedTo: drepper at redhat dot com
        ReportedBy: zhenhua2000 at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: X86
  GCC host triplet: X86
GCC target triplet: X86


http://sourceware.org/bugzilla/show_bug.cgi?id=11501

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]