Re: BUG #1736: endless loop in PQconnectdb

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Karsten Desler <kdesler(at)soohrt(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1736: endless loop in PQconnectdb
Date: 2005-07-02 23:07:13
Message-ID: 200507022307.j62N7D425259@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Karsten Desler wrote:
> * Karsten Desler wrote:
> > * Bruce Momjian wrote:
> > > Yes, please --- the patch is at:
> > >
> > > http://archives.postgresql.org/pgsql-patches/2005-06/msg00486.php
> >
> > Thanks.
> > I've applied the patch now, and I'll keep you posted.
>
> It doesn't seem to have helped, and while poking around a little, I
> found another annoyance. libpq seems to leak memory if I pass a dns name as
> host in conninfo. It doesn't leak when I do the getaddrinfo myself and pass
> an IP.
>
> root 16580 0.0 0.2 4004 1304 ? S 10:07 0:00 monitor xxx.xxx.xxx.xxx
> root 22434 0.0 1.9 47328 9240 ? S Jun07 5:42 monitor xxx.xxx.xxx.yyy
>
> ==9980== 4648 bytes in 166 blocks are definitely lost in loss record 4 of 4
> ==9980== at 0x1B90459D: malloc (vg_replace_malloc.c:130)
> ==9980== by 0x1BC39E3B: (within /lib/tls/i686/cmov/libresolv-2.3.2.so)
> ==9980== by 0x1BC38B92: __libc_res_nquery (in /lib/tls/i686/cmov/libresolv-2.3.2.so)
> ==9980== by 0x1BC39289: (within /lib/tls/i686/cmov/libresolv-2.3.2.so)
> ==9980== by 0x1BC38E8F: __libc_res_nsearch (in /lib/tls/i686/cmov/libresolv-2.3.2.so)
> ==9980== by 0x1BDA907D: ???
> ==9980== by 0x1B9F0A65: (within /lib/tls/i686/cmov/libc-2.3.2.so)
> ==9980== by 0x1B9F1673: getaddrinfo (in /lib/tls/i686/cmov/libc-2.3.2.so)
> ==9980== by 0x1B9259A1: getaddrinfo_all (in /usr/lib/libpq.so.3.1)
> ==9980== by 0x1B916F3B: (within /usr/lib/libpq.so.3.1)
> ==9980== by 0x1B9164E9: PQconnectStart (in /usr/lib/libpq.so.3.1)
> ==9980== by 0x1B916471: PQconnectdb (in /usr/lib/libpq.so.3.1)

I think what you are seeing is that the getaddrinfo memory is placed in
the PGconn structure that isn't freed until PQclear is called. Does
your test call PQclear()?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Karsten Desler 2005-07-03 08:58:15 Re: BUG #1736: endless loop in PQconnectdb
Previous Message Tom Lane 2005-07-02 16:44:25 Re: BUG #1747: PostgreSQL 'hangs' after prolonged usage