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 1kDWhI-0006si-Me for pgsql-bugs@arkaria.postgresql.org; Wed, 02 Sep 2020 17:37:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDWhH-0006Be-L8 for pgsql-bugs@arkaria.postgresql.org; Wed, 02 Sep 2020 17:37:23 +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 1kDWhH-0006BW-3T for pgsql-bugs@lists.postgresql.org; Wed, 02 Sep 2020 17:37:23 +0000 Received: from mail.dalibo.com ([212.85.157.172]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDWhD-00066I-TI for pgsql-bugs@lists.postgresql.org; Wed, 02 Sep 2020 17:37:21 +0000 Received: from firost (larco.ioguix.net [82.66.0.6]) by mail.dalibo.com (Postfix) with ESMTPSA id 7C21A2001D for ; Wed, 2 Sep 2020 19:37:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1599068236; bh=buEpSwy0NJT/98VyJPWSKvsB5V8kSzLIrBnaXKl6avs=; h=Date:From:To:Subject:From; b=VALXS7laB8VpD67ZBoQ8gtKgAo1+nZKTLmB5GgVAx4xFJWk2GfiuETBhOb6/h1kST rq+NtTg6YhfKTWi3/trFiBWhZhiV19kXpqq3+Tw6Nv6MRSS5G9SfZoHeql+5A7yXxi 22n4X1WdFymCbLJPBaROMFyu0HznVA3PJaxmQx+Y= Date: Wed, 2 Sep 2020 19:37:15 +0200 From: Jehan-Guillaume de Rorthais To: pgsql-bugs@lists.postgresql.org Subject: [BUG v13] Crash with event trigger in extension Message-ID: <20200902193715.6e0269d4@firost> Organization: Dalibo MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/06PBa_U1mCKA/uP.0iNtdc+" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --MP_/06PBa_U1mCKA/uP.0iNtdc+ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, Philippe Beaudoin reported to me a crash he was able to reproduce with some extension update script. Please, find in attachment a script that triggers it. Just edit the three first vars to point to a temporary installation and instance. Some git bisect shows the bug was introduced by b5810de3f4, where multi-statement query strings are using different short memory contexts. To make it short, any ALTER TABLE command in an extension script is currently calling lappend to add its command to the currentEventTriggerState->commandList list from its own short context instead of using the context of currentEventTriggerState. Because of this, when we call EventTriggerCollectSimpleCommand() for the top level "ALTER EXTENSION" query, the list has long been removed and a new call of lappend on currentEventTriggerState->commandList raise Assert(IsPointerList(list)). Please, find in attachement a bug fix proposal. I did a very quick look at other ->commandList manipulations in event_trigger.c. They all appear to be in the correct context in a first look. Regards, --MP_/06PBa_U1mCKA/uP.0iNtdc+ Content-Type: application/octet-stream; name=bug-ext.bash Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=bug-ext.bash IyEvYmluL2Jhc2gKCnNob3B0IC1zIC1vIGVycmV4aXQgbm91bnNldAoKUEdCSU49Ii90bXAvYnVn X2V4dC9iaW4vIgpQR0RBVEE9Ii90bXAvYnVnX2V4dC9kYXRhIgpQR0xPRz0iL3RtcC9idWdfZXh0 L3Bvc3RncmVzcWwubG9nIgpQR0VYVERJUj0iJCgiJFBHQklOIi9wZ19jb25maWcgLS1zaGFyZWRp cikvZXh0ZW5zaW9uIgoKZXhwb3J0IFBHUE9SVD01NDM5CgpybSAtcmYgIiRQR0RBVEEiCiIkUEdC SU4iL2luaXRkYiAtVSBwb3N0Z3JlcyAiJFBHREFUQSIKCnRvdWNoICIkUEdFWFRESVIiL2J1Z2dp bmdleH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B0cnVlCgpybSAtcmYg IiRQR0RBVEEiCnJtICIkUEdFWFRESVIiL2J1Z2dpbmdleHQqCg== --MP_/06PBa_U1mCKA/uP.0iNtdc+ Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=v1-0001-Fix-crash-with-alter-table-event-triggers-in-extensi.patch