pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Simplex <hypercube.mail@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: memory leak in libpq , definitely lost: 200 bytes in 1 blocks, indirectly lost: 2,048 bytes in 1 blocks ...
Date: Mon, 10 Oct 2016 10:44:04 -0400
Message-ID: <32026.1476110644@sss.pgh.pa.us> (raw)
In-Reply-To: <b0a69fbe-f784-b429-2cac-adf692cf0c56@iki.fi>
References: <CAD-Qf1eLUtBOTPXyFQGW-4eEsop31tVVdZPu4kL9pbQ6tJPO8g@mail.gmail.com>
	<b0a69fbe-f784-b429-2cac-adf692cf0c56@iki.fi>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Heikki Linnakangas <hlinnaka@iki.fi> writes:
> On 10/10/2016 12:38 PM, Simplex wrote:
>> } Repeat several times to get the leak

> I was not able to reproduce this.

I was able to reproduce it, or at least something that looks similar,
after a good deal of fooling around.  I needed:

* SSL turned on
* server recovering from crash, so that it rejects at least one connection
  attempt with "the database system is starting up"

This causes the successful PQreset call to leave an async result behind
containing the earlier connection rejection message.  That might or might
not be a logic bug in PQreset, but it doesn't really seem all that wrong.
But then the PQexec calls PQsendQueryStart which cavalierly resets
conn->result to NULL, leaking the async result.  I fixed PQsendQueryStart
to use pqClearAsyncResult which is less cavalier, and then I couldn't
reproduce the leak anymore.

Interestingly, I couldn't make it happen (ie get to PQsendQueryStart with
a non-null result) without valgrind active on the client --- so there's
some timing considerations involved too, apparently.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (3+ messages)

Message-ID: <32026.1476110644@sss.pgh.pa.us>
Permalink:  ../32026.1476110644@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/32026.1476110644@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, hlinnaka@iki.fi, hypercube.mail@gmail.com
  Subject: Re: memory leak in libpq , definitely lost: 200 bytes in 1 blocks, indirectly lost: 2,048 bytes in 1 blocks ...
  In-Reply-To: <32026.1476110644@sss.pgh.pa.us>
  References: <CAD-Qf1eLUtBOTPXyFQGW-4eEsop31tVVdZPu4kL9pbQ6tJPO8g@mail.gmail.com> <b0a69fbe-f784-b429-2cac-adf692cf0c56@iki.fi> <32026.1476110644@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox