leak in libpq, getpwuid - Mailing list pgsql-general

From Grzegorz Jaśkiewicz
Subject leak in libpq, getpwuid
Date
Msg-id 2f4958ff0902170533w5d520d1bv91a7239c9079aacb@mail.gmail.com
Whole thread Raw
Responses Re: leak in libpq, getpwuid
Re: leak in libpq, getpwuid
List pgsql-general
Hey folks,

I am getting leaks on my machine, valgrind points to getpwuid_r called
by libpq's PQConnectDb()

==11784== 32,772 bytes in 1 blocks are indirectly lost in loss record 31 of 31
==11784==    at 0x4004BA2: calloc (vg_replace_malloc.c:397)
==11784==    by 0x63D9FCB: ???
==11784==    by 0x63C10FD: ???
==11784==    by 0x63AF5BE: ???
==11784==    by 0x63AFB4D: ???
==11784==    by 0x63A0C0E: ???
==11784==    by 0x63A3520: ???
==11784==    by 0x63A42BD: ???
==11784==    by 0x63A4A86: ???
==11784==    by 0x63A513F: ???
==11784==    by 0x4949C1: getpwuid_r@@GLIBC_2.1.2 (in /lib/libc-2.8.so)
==11784==    by 0x297F2D: (within /usr/lib/libpq.so.5.1)
==11784==    by 0x283050: (within /usr/lib/libpq.so.5.1)
==11784==    by 0x287118: (within /usr/lib/libpq.so.5.1)
==11784==    by 0x287269: (within /usr/lib/libpq.so.5.1)
==11784==    by 0x2875AE: PQconnectStart (in /usr/lib/libpq.so.5.1)
==11784==    by 0x287601: PQconnectdb (in /usr/lib/libpq.so.5.1)


The application fires up few threads once in a while, and they connect
to db on different hosts.
What matters, is that after few days it started to fail in
pthread_create(), because of memory problems.

And looks like this is causing the problem. Please note that it
happends on both 8.3 and 8.4, in the same way (above backtrace is from
8.4).
Any ideas ?
I call PGconnectdb, and than PQfinish, on that test - it can't connect
because db is down.
Now, I am very sure that PQfinish is called.
Since no connection exists during that test, nothing else is called in libpq.

Any ideas ?

--
GJ

pgsql-general by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: hi all
Next
From: Grzegorz Jaśkiewicz
Date:
Subject: Re: leak in libpq, getpwuid