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 1kXUX5-0001IS-Lx for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Oct 2020 19:21:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kXUX4-0003QA-KA for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Oct 2020 19:21:22 +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 1kXUX4-0003Q3-DB for pgsql-hackers@lists.postgresql.org; Tue, 27 Oct 2020 19:21:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kXUX2-0003lH-Dz for pgsql-hackers@postgresql.org; Tue, 27 Oct 2020 19:21:21 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 09RJL77s1093135; Tue, 27 Oct 2020 15:21:08 -0400 From: Tom Lane To: Arseny Sher cc: pgsql-hackers , Alvaro Herrera Subject: Re: Use-after-free in 12- EventTriggerAlterTableEnd In-reply-to: <877drcyprb.fsf@ars-thinkpad> References: <877drcyprb.fsf@ars-thinkpad> Comments: In-reply-to Arseny Sher message dated "Tue, 27 Oct 2020 12:36:24 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1093131.1603826467.1@sss.pgh.pa.us> Date: Tue, 27 Oct 2020 15:21:07 -0400 Message-ID: <1093133.1603826467@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Arseny Sher writes: > Valgrind on our internal buildfarm complained about use-after-free > during currentEventTriggerState->commandList manipulations, e.g. lappend > in EventTriggerCollectSimpleCommand. I've discovered that the source of > problem is EventTriggerAlterTableEnd not bothering to switch into its > own context before appending to the list. ced138e8cba fixed this in > master and 13 but wasn't backpatched further, so I see the problem in > 12-. Yeah, that clearly should have been back-patched --- the fact that it accidentally didn't fail in the most common case wasn't a good reason for leaving the bug in place. I'm not excited about the test case ced138e8cba added though, so I think your proposed patch is fine. Will push shortly. regards, tom lane