leak in libpq, getpwuid

Started by Grzegorz Jaśkiewiczabout 17 years ago8 messagesgeneral
Jump to latest
#1Grzegorz Jaśkiewicz
gryzman@gmail.com

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

#2Grzegorz Jaśkiewicz
gryzman@gmail.com
In reply to: Grzegorz Jaśkiewicz (#1)
Re: leak in libpq, getpwuid

oh, and note that I kind of rulled out linux libc/distro problem, same
happens on both centos 4.7 and fedora 9.
strangely.

#3Bruce Momjian
bruce@momjian.us
In reply to: Grzegorz Jaśkiewicz (#1)
Re: leak in libpq, getpwuid

Grzegorz Ja��kiewicz wrote:

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.

That is kind of odd, considering that getpwuid_r() shouldn't be
allocating any memory at all --- in fact, the reason we use it is
because we pass the memory it uses for storage.

The only thing I can suggest is posting the application source code
somewhere in hopes we can see the problem somewhere.

I have never heard of a similar report, so odds are there is something
wierd happening in your application.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#4Grzegorz Jaśkiewicz
gryzman@gmail.com
In reply to: Bruce Momjian (#3)
Re: leak in libpq, getpwuid

thanks Bruce,
In fact - the more weird fact is, that it still happens on
fedora9+8.4, but I can't get it anymore on centos+8.3.5

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Grzegorz Jaśkiewicz (#2)
Re: leak in libpq, getpwuid

=?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?= <gryzman@gmail.com> writes:

oh, and note that I kind of rulled out linux libc/distro problem, same
happens on both centos 4.7 and fedora 9.

That hardly constitutes a wide sample of linux distros ...

regards, tom lane

#6Grzegorz Jaśkiewicz
gryzman@gmail.com
In reply to: Tom Lane (#5)
Re: leak in libpq, getpwuid

On Tue, Feb 17, 2009 at 4:03 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

=?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?= <gryzman@gmail.com> writes:

oh, and note that I kind of rulled out linux libc/distro problem, same
happens on both centos 4.7 and fedora 9.

That hardly constitutes a wide sample of linux distros ...

same thing on debian, well - almost:

==8261== at 0x4023D6E: malloc (vg_replace_malloc.c:207)
==8261== by 0x43B1930: (within /lib/i686/cmov/libc-2.7.so)
==8261== by 0x43B222B: __nss_database_lookup (in /lib/i686/cmov/libc-2.7.so)
==8261== by 0x6C98F5B: ???
==8261== by 0x6C9B0B4: ???
==8261== by 0x4358ED1: getpwuid_r (in /lib/i686/cmov/libc-2.7.so)
==8261== by 0x417ED3D: (within /usr/lib/libpq.so.5.1)
==8261== by 0x416A7A8: (within /usr/lib/libpq.so.5.1)
==8261== by 0x416E5CA: (within /usr/lib/libpq.so.5.1)
==8261== by 0x416E709: (within /usr/lib/libpq.so.5.1)
==8261== by 0x416EA4E: PQconnectStart (in /usr/lib/libpq.so.5.1)
==8261== by 0x416EAA1: PQconnectdb (in /usr/lib/libpq.so.5.1)

--
GJ

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Grzegorz Jaśkiewicz (#6)
Re: leak in libpq, getpwuid

=?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?= <gryzman@gmail.com> writes:

same thing on debian, well - almost:

==8261== at 0x4023D6E: malloc (vg_replace_malloc.c:207)
==8261== by 0x43B1930: (within /lib/i686/cmov/libc-2.7.so)
==8261== by 0x43B222B: __nss_database_lookup (in /lib/i686/cmov/libc-2.7.so)
==8261== by 0x6C98F5B: ???
==8261== by 0x6C9B0B4: ???
==8261== by 0x4358ED1: getpwuid_r (in /lib/i686/cmov/libc-2.7.so)
==8261== by 0x417ED3D: (within /usr/lib/libpq.so.5.1)
==8261== by 0x416A7A8: (within /usr/lib/libpq.so.5.1)
==8261== by 0x416E5CA: (within /usr/lib/libpq.so.5.1)
==8261== by 0x416E709: (within /usr/lib/libpq.so.5.1)
==8261== by 0x416EA4E: PQconnectStart (in /usr/lib/libpq.so.5.1)
==8261== by 0x416EAA1: PQconnectdb (in /usr/lib/libpq.so.5.1)

[ shrug... ] You're bugging the wrong people about this. A leak
inside getpwuid_r is a glibc bug, not our bug.

regards, tom lane

#8Grzegorz Jaśkiewicz
gryzman@gmail.com
In reply to: Tom Lane (#7)
Re: leak in libpq, getpwuid

On Wed, Feb 18, 2009 at 5:47 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

=?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?= <gryzman@gmail.com> writes:

same thing on debian, well - almost:

==8261== at 0x4023D6E: malloc (vg_replace_malloc.c:207)
==8261== by 0x43B1930: (within /lib/i686/cmov/libc-2.7.so)
==8261== by 0x43B222B: __nss_database_lookup (in /lib/i686/cmov/libc-2.7.so)
==8261== by 0x6C98F5B: ???
==8261== by 0x6C9B0B4: ???
==8261== by 0x4358ED1: getpwuid_r (in /lib/i686/cmov/libc-2.7.so)
==8261== by 0x417ED3D: (within /usr/lib/libpq.so.5.1)
==8261== by 0x416A7A8: (within /usr/lib/libpq.so.5.1)
==8261== by 0x416E5CA: (within /usr/lib/libpq.so.5.1)
==8261== by 0x416E709: (within /usr/lib/libpq.so.5.1)
==8261== by 0x416EA4E: PQconnectStart (in /usr/lib/libpq.so.5.1)
==8261== by 0x416EAA1: PQconnectdb (in /usr/lib/libpq.so.5.1)

[ shrug... ] You're bugging the wrong people about this. A leak
inside getpwuid_r is a glibc bug, not our bug.

thought so, but it is good to check on both sides of fence.
thanks

--
GJ