Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btboX-0004vf-Cd for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Oct 2016 14:44:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1btboW-0001Ky-VN for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Oct 2016 14:44:25 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1btboW-0001KF-0P for pgsql-bugs@postgresql.org; Mon, 10 Oct 2016 14:44:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1btboP-0008Fq-T8 for pgsql-bugs@postgresql.org; Mon, 10 Oct 2016 14:44:22 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u9AEi4CS032027; Mon, 10 Oct 2016 10:44:04 -0400 From: Tom Lane To: Heikki Linnakangas cc: Simplex , 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 ... In-reply-to: References: Comments: In-reply-to Heikki Linnakangas message dated "Mon, 10 Oct 2016 17:14:59 +0300" Date: Mon, 10 Oct 2016 10:44:04 -0400 Message-ID: <32026.1476110644@sss.pgh.pa.us> X-Pg-Spam-Score: -2.2 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Heikki Linnakangas 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