Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YfYeR-00025m-3B for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Apr 2015 18:55:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YfYeP-0003Fz-VF for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Apr 2015 18:55:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YfYeN-0003Ff-Sn for pgsql-bugs@postgresql.org; Tue, 07 Apr 2015 18:55:04 +0000 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YfYeI-0002C1-So for pgsql-bugs@postgresql.org; Tue, 07 Apr 2015 18:55:02 +0000 Received: by wgin8 with SMTP id n8so65759656wgi.0 for ; Tue, 07 Apr 2015 11:54:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=p37H98FFkzFDO9/R8hYsL8+ymtiSCPx+4SPVj/4C8QQ=; b=SmScsqcZhyr6hCty5lUHgG+XlaYjAi77ps3AuqC83FIT6YvmPXDadyyA5M1BgEfx6f FEKiQLeXqOxAKpS6VyXpyvTOoCE0d1HI48tWiy0oKgoPIGPJTn55wpT/NWg1ckAO8FZK tScmqky/5OAqdJ8HPsyXV1o2lyrRDn2ilPU87Jf8QCabcxh+3zdQfk98pZC7zFz6t1pl tewYlPwNZLKyNt3vWt3jc0nyfsAbO0k/cFbVJdgFimN9pOd9cDfngwfUHujTrmSMS3pf smy5925/y8OTUmlqtRerlihqZ97XDYjk9ZuXiaF+D8j9rb7HrRyDrrPKFtEPnP9Ktb9Y eNxg== X-Received: by 10.194.187.16 with SMTP id fo16mr39724729wjc.86.1428432896541; Tue, 07 Apr 2015 11:54:56 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by mx.google.com with ESMTPSA id vq9sm12182211wjc.6.2015.04.07.11.54.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Apr 2015 11:54:55 -0700 (PDT) Message-ID: <552427FC.6060302@iki.fi> Date: Tue, 07 Apr 2015 21:54:52 +0300 From: Heikki Linnakangas Reply-To: hlinnaka@iki.fi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.5.0 MIME-Version: 1.0 To: Michael Paquier CC: Tom Lane , Pg Bugs Subject: Re: PQexec() hangs on OOM References: <547480DE.4040408@vmware.com> <25150.1428328002@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.3 (--) 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 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