Re: BUG #1736: endless loop in PQconnectdb - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: BUG #1736: endless loop in PQconnectdb
Date
Msg-id 200507022307.j62N7D425259@candle.pha.pa.us
Whole thread Raw
In response to Re: BUG #1736: endless loop in PQconnectdb  (Karsten Desler <kdesler@soohrt.org>)
Responses Re: BUG #1736: endless loop in PQconnectdb  (Karsten Desler <kdesler@soohrt.org>)
List 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@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #1747: PostgreSQL 'hangs' after prolonged usage
Next
From: "Greg Steffensen"
Date:
Subject: BUG #1748: Unique contraints cannot be added to long text fields