pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Pg Bugs <pgsql-bugs@postgresql.org>
Subject: Re: PQexec() hangs on OOM
Date: Tue, 07 Apr 2015 21:54:52 +0300
Message-ID: <552427FC.6060302@iki.fi> (raw)
In-Reply-To: <CAB7nPqQPaDb+=GCkdZb1L-VbpJTiigPx9_UNTA1a4H2MLGi9XA@mail.gmail.com>
References: <547480DE.4040408@vmware.com>
	<CAB7nPqR8UtXpTOkKOuxhhXM8PzcPa4dQDKE6rYx+tZhPrQQNWg@mail.gmail.com>
	<CAB7nPqSb3RF=s+BDyq1Un2+rng20EQQyxajdTRtpRG7XsyuLnw@mail.gmail.com>
	<25150.1428328002@sss.pgh.pa.us>
	<CAB7nPqQPaDb+=GCkdZb1L-VbpJTiigPx9_UNTA1a4H2MLGi9XA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 04/07/2015 09:18 AM, Michael Paquier wrote:
> @@ -143,7 +143,11 @@ PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
>
>  	result = (PGresult *) malloc(sizeof(PGresult));
>  	if (!result)
> +	{
> +		printfPQExpBuffer(&conn->errorMessage,
> +						  libpq_gettext("out of memory\n"));
>  		return NULL;
> +	}
>
>  	result->ntups = 0;
>  	result->numAttributes = 0;

That's not cool, because PQmakeEmptyPGresult may be called with conn == 
NULL. In general, I'm a bit wary of changing PQmakeEmptyResult so that 
it sets the error message. Will have to check all the callers carefully 
to see if that would upset any of them. And it might be called by 
applications too.

> I have noticed as well that getCopyStart() in fe-protocol3.c needs to
> be made a little bit smarter to make the difference between an OOM and
> the not-enough-data type of problem.

Yeah. getParamDescription still has the issue, with your patch.

> This problem has a low probability to happen in the field, and no
> people complained about that as well, so I think that patching only
> HEAD is adapted.

As long as the patch applies easily, I don't see much reason to not 
backpatch.

- Heikki



-- 
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 (48+ messages)  latest in thread

Message-ID: <552427FC.6060302@iki.fi>
Permalink:  ../552427FC.6060302@iki.fi/
Also on:    postgresql.org/message-id/552427FC.6060302@iki.fi

 · 

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: hlinnaka@iki.fi, michael.paquier@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: PQexec() hangs on OOM
  In-Reply-To: <552427FC.6060302@iki.fi>
  References: <547480DE.4040408@vmware.com> <CAB7nPqR8UtXpTOkKOuxhhXM8PzcPa4dQDKE6rYx+tZhPrQQNWg@mail.gmail.com> <CAB7nPqSb3RF=s+BDyq1Un2+rng20EQQyxajdTRtpRG7XsyuLnw@mail.gmail.com> <25150.1428328002@sss.pgh.pa.us> <CAB7nPqQPaDb+=GCkdZb1L-VbpJTiigPx9_UNTA1a4H2MLGi9XA@mail.gmail.com> <552427FC.6060302@iki.fi>

* 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