pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: tbutz@optitool.de
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16095: Segfault while executing trigger
Date: Tue, 05 Nov 2019 14:37:43 -0500
Message-ID: <7504.1572982663@sss.pgh.pa.us> (raw)
In-Reply-To: <20191105191039.lpd4h3rddwbtjblc@alap3.anarazel.de>
References: <16095-c3ff2e5283b8dba5@postgresql.org>
	<12120.1572975512@sss.pgh.pa.us>
	<20191105191039.lpd4h3rddwbtjblc@alap3.anarazel.de>

Andres Freund <andres@anarazel.de> writes:
> On 2019-11-05 12:38:32 -0500, Tom Lane wrote:
>> So pretty clearly, this slot has a null bslot->base.tuple pointer and
>> yet its TTS_FLAG_SHOULDFREE flag is set.

> Hm. It seems quite likely that this is yet another report of:
> commit d986d4e87f61c68f52c68ebc274960dc664b7b4e
>     Fix crash caused by EPQ happening with a before update trigger present.
> The copying of a slot into itself yielded precisely this symptom, a slot
> with shouldfree set, but without a tuple associated.

Thomas, can you try with that patch and see if it fixes the problem
for you?  We're quite close to 12.1 release, so if there's more to fix,
it'd be better to find out ASAP.

Note that this theory requires that the query we see being executed within
a BEFORE UPDATE trigger had itself fired a BEFORE UPDATE trigger, and that
there'd been concurrent commits causing EPQ to run.  That doesn't seem
exactly implausible, but it's data not evident in your report.


>> Wondering about how that could be, I notice that execTuples.c seems
>> to have a bad coding pattern of setting TTS_FLAG_SHOULDFREE *before*
>> the pointer is valid.  Eg, in tts_buffer_heap_materialize, a failure
>> in heap_form_tuple would leave the slot in an inconsistent state.
>> I'm not sure that that explains this report, because we typically
>> would not run ExecutorEnd on a plan tree that had failed, but I'm
>> still strongly inclined to run around and move those flag-setting
>> steps down a bit.  Andres, any objection?

> No objection here.

OK, I'll take a look at that tomorrow or so.  It's probably just
cosmetic, but it makes me itch anyway.

			regards, tom lane





view thread (8+ messages)  latest in thread

Message-ID: <7504.1572982663@sss.pgh.pa.us>
Permalink:  ../7504.1572982663@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7504.1572982663@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, tbutz@optitool.de
  Subject: Re: BUG #16095: Segfault while executing trigger
  In-Reply-To: <7504.1572982663@sss.pgh.pa.us>
  References: <16095-c3ff2e5283b8dba5@postgresql.org> <12120.1572975512@sss.pgh.pa.us> <20191105191039.lpd4h3rddwbtjblc@alap3.anarazel.de> <7504.1572982663@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox