Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bALQJ-0002Z6-Ux for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Jun 2016 18:08:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bALQJ-0006JR-HU for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Jun 2016 18:08:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bALPg-0005bS-9R for pgsql-bugs@postgresql.org; Tue, 07 Jun 2016 18:07:40 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bALPd-0002t8-P5 for pgsql-bugs@postgresql.org; Tue, 07 Jun 2016 18:07:39 +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 u57I7W0c020106; Tue, 7 Jun 2016 14:07:32 -0400 From: Tom Lane To: =?iso-8859-1?Q?Bo_=D8rsted_Andresen?= cc: Andres Freund , "pgsql-bugs@postgresql.org" Subject: Re: BUG #14180: Segmentation fault on replication slave In-reply-to: References: <20160607091618.1385.29368@wrigleys.postgresql.org> <20160607172115.7pty2qzptgkw5fxg@alap3.anarazel.de> <20160607174042.dskfqhcjrr5lufwi@alap3.anarazel.de> Comments: In-reply-to =?iso-8859-1?Q?Bo_=D8rsted_Andresen?= message dated "Tue, 07 Jun 2016 17:53:46 -0000" Date: Tue, 07 Jun 2016 14:07:32 -0400 Message-ID: <20105.1465322852@sss.pgh.pa.us> X-Pg-Spam-Score: -3.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 =?iso-8859-1?Q?Bo_=D8rsted_Andresen?= writes: >> On 2016-06-07 19:41, Andres Freund wrote: >> Any chance the running version of postgres is out of date with the installed >> binaries / debug symbols? > You mean that I upgraded without restarting postgres before the segfault? I think the reason for the lack of useful backtrace info is that we've smashed the stack. Note that the original report shows i == 3324 which is much larger than the available length of the local items[] array (408). So presumably, the passed-in "len" was bogus (much too large). If you're prepared to build a custom version of Postgres, you could try adding this to _bt_restore_page(): /* Need to copy tuple header due to alignment considerations */ memcpy(&itupdata, from, sizeof(IndexTupleData)); itemsz = IndexTupleDSize(itupdata); itemsz = MAXALIGN(itemsz); + if (i >= lengthof(items)) + elog(PANIC, "too many items on btree page"); + items[i] = (Item) from; itemsizes[i] = itemsz; i++; from += itemsz; and then you should get a core dump before the stack is clobbered. I wonder whether we shouldn't add such a check to the regular sources... 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