Re: BUG #17607: Server process crashes when PLpgSQL function raises error in subtransaction

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: thomas.d.mckay@gmail.com
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, pgsql-bugs@lists.postgresql.org
Date: 2022-09-05T17:16:19Z
Lists: pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> I've encountered a bug while doing some SQL migrations on a PostgreSQL 13.8
> server. My initial use-case is a Django app running migrations, a test setup
> and a test, but that code was more than 10K lines of DDL, so I've reduced
> the code to a minimal reproducible example (as best I could).

Thanks for the minimal reproducer!  I confirm that this problem is visible
in the v12 and v13 branches, but not before or after.  On the master
branch, it was introduced at

Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
Branch: master Release: REL_14_BR [25936fd46] 2021-02-27 18:09:15 -0300
    Fix use-after-free bug with AfterTriggersTableData.storeslot

and repaired, seemingly accidentally, by

Author: Tom Lane <tgl@sss.pgh.pa.us>
Branch: master Release: REL_14_BR [c5b7ba4e6] 2021-04-06 15:57:11 -0400
    Postpone some stuff out of ExecInitModifyTable.

25936fd46 was back-patched into v12 and v13, which is why they show
the bug.  c5b7ba4e6 was not back-patched, both because it'd be way too
invasive and because we weren't aware that it was fixing anything.
I'm not really sure that it *did* fix anything --- perhaps there are
variants of this example that still fail?

cc'ing Alvaro for comment.

			regards, tom lane



Commits

  1. Fix tupdesc lifespan bug with AfterTriggersTableData.storeslot.