Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aaSgC-0003oX-B3 for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Feb 2016 18:36:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aaSgB-0007M5-RK for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Feb 2016 18:36:23 +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) (envelope-from ) id 1aaSfY-0005vz-5y for pgsql-bugs@postgresql.org; Mon, 29 Feb 2016 18:35:44 +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) (envelope-from ) id 1aaSfR-0004Zv-BQ for pgsql-bugs@postgresql.org; Mon, 29 Feb 2016 18:35:43 +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 u1TIZTkG018588; Mon, 29 Feb 2016 13:35:29 -0500 From: Tom Lane To: Andres Freund cc: "Shulgin, Oleksandr" , Alvaro Herrera , chris.tessels@inergy.nl, Pg Bugs Subject: Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION In-reply-to: <20160225172958.t7pdlt4puydblchx@alap3.anarazel.de> References: <20160224125824.2573.27524@wrigleys.postgresql.org> <20160224205237.GA438345@alvherre.pgsql> <20160224215221.bbbduc5nelq7tf6s@alap3.anarazel.de> <5857.1456411909@sss.pgh.pa.us> <20160225170311.qi3h6zbzf4mscdtj@alap3.anarazel.de> <29282.1456420806@sss.pgh.pa.us> <20160225172958.t7pdlt4puydblchx@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Thu, 25 Feb 2016 09:29:58 -0800" Date: Mon, 29 Feb 2016 13:35:29 -0500 Message-ID: <18587.1456770929@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 Andres Freund writes: > On 2016-02-25 12:20:06 -0500, Tom Lane wrote: >> Seems like we can either (1) get rid of that memmove in favor of >> a handwritten loop, or (2) give up on unlocked access to the >> pgprocnos array. Which performance hit would you rather take? > I think 1), while it'll be noticeable, it's probably going to degrade > much more gracefully. > I think we additionally also should add a security check to > MinimumActiveBackends that prevents a pgprocno above the max number of > backends to be seen as valid. So we have three proposals on the table: * volatile-ize arrayP * range-check the pgprocno after we fetch it * replace memmove(s) with int-at-a-time move loop(s) I wonder whether we couldn't leave the memmoves alone if we do the other two things. It would mean that MinimumActiveBackends would sometimes miss examining some backends, but that's going to happen anyway given its use of unlocked access. 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