Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YgGTW-0007WR-9n for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Apr 2015 17:42:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YgGTV-0006sh-Gn for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Apr 2015 17:42:45 +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 1YgGTU-0006sX-Pj for pgsql-bugs@postgresql.org; Thu, 09 Apr 2015 17:42:44 +0000 Received: from mail-wi0-x22a.google.com ([2a00:1450:400c:c05::22a]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YgGTQ-0005F8-82 for pgsql-bugs@postgresql.org; Thu, 09 Apr 2015 17:42:43 +0000 Received: by wiaa2 with SMTP id a2so107699423wia.0 for ; Thu, 09 Apr 2015 10:42:38 -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=wcZu/Mi9dxmBLf7YRUiNYakmiRuvkdh7qoWiobgHd3g=; b=LLMrdWjjCitF4zutNbFN6Viw7vZ6hcBeh4G6hDU7pSctjKo4wGfZBUwxja07IBAvD/ rbAyCfu0/9c6stJUSymKq1Ef3QrkywBq71ttprQTCxEJBEz5o7pw0+PUkggdb7pL9o8s Ww83gd7vvYZIS0AzaEakQQURjE+gdgvPJLD5kYWe3+rW3KHgTt1Zv/w1REz5S13OelXJ qQmDbFEG+qadV5fa5Wq7vOKUxT+N7fJYXvvzm0UBiiGh5AHky2O/oDqmpksbtX8B404S twQB8R1CM79VISIqp6evlIbtHEef8pm1lkkWT5ca/oBaCe0CbgDO1XEMrijez294M6Vu +FJg== X-Received: by 10.181.13.198 with SMTP id fa6mr8269434wid.41.1428601358089; Thu, 09 Apr 2015 10:42:38 -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 i8sm21068539wiy.23.2015.04.09.10.42.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Apr 2015 10:42:36 -0700 (PDT) Message-ID: <5526BA0A.4090600@iki.fi> Date: Thu, 09 Apr 2015 20:42:34 +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> <552427FC.6060302@iki.fi> 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/08/2015 07:27 AM, Michael Paquier wrote: > On Wed, Apr 8, 2015 at 3:54 AM, Heikki Linnakangas wrote: >> On 04/07/2015 09:18 AM, Michael Paquier wrote: >>> 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. > > Check. There are still a few parseInput subroutines that have similar issues. In fe-protocol2.c: * pqGetErrorNotice2 returns EOF if there is not enough data, but also on OOM. The caller assumes it's because not enough data. * getRowDescriptions() is the same, although it sets conn->errorMessage on OOM. * getAnotherTuple() is the same, but it also skips over the received data, so you won't get stuck. So maybe that's OK. * getNotify() just drops any NOTIFY messages on OOM. Perhaps that's OK.. The corresponding functions in fe-protocol3.c are pretty much identical, with the same issues. In addition: * getParameterStatus will act as if the parameter value was "out of memory". That'll be fun for something like client_encoding or standard_conforming_strings. Would be good to use a small char[100] variable, in stack, if it fits, and only use malloc for larger values. That would cover all the common variables that need to be machine-parsed. - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs