Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQEPw-0002Gd-QT for pgsql-bugs@arkaria.postgresql.org; Sun, 19 Apr 2020 18:11:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jQEPv-0001HZ-6e for pgsql-bugs@arkaria.postgresql.org; Sun, 19 Apr 2020 18:11:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQEPv-0001HS-0Y for pgsql-bugs@lists.postgresql.org; Sun, 19 Apr 2020 18:11:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQEPr-0008QG-ER for pgsql-bugs@lists.postgresql.org; Sun, 19 Apr 2020 18:11:41 +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 03JIBb6r004546; Sun, 19 Apr 2020 14:11:37 -0400 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16378: Invalid memory access on interrupting CLUSTER after CREATE TEMP TABLE In-reply-to: <16378-7a70ca41b3ec2009@postgresql.org> References: <16378-7a70ca41b3ec2009@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Sun, 19 Apr 2020 07:07:08 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4544.1587319897.1@sss.pgh.pa.us> Date: Sun, 19 Apr 2020 14:11:37 -0400 Message-ID: <4545.1587319897@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > The following script: > ... > leads to a cassert-enabled server crash with the following messages in the > log (for the master branch): Hm, I can get a crash here without valgrind, as long as it's a cassert build. We're accessing a list that's been thrown away by memory context cleanup, so this results: TRAP: FailedAssertion("IsOidList(list)", File: "list.c", Line: 678) The timing is a bit finicky, but no more so than you report for the valgrind case. The difficulty is that the pendingReindexedIndexes list is kept in some transaction-local context, so it gets flushed during the transaction abort that is the first step of proc_exit processing. But the static pointer to it is still set, causing big problems if we do any system catalog accesses later --- like, say, while dropping the session's temp tables. One idea would be to keep the list in TopMemoryContext, but that feels like a band-aid solution. I think more likely what we ought to do is stop trying to use a PG_TRY in reindex_relation to drive cleanup, and instead hook ResetReindexPending into transaction abort processing honestly. I wonder how many other uses of PG_TRY have similar issues? It's not really obvious that this is an unsafe coding pattern. regards, tom lane