pgsql: MemoryContextCreate: assert parent is valid and different from n

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: MemoryContextCreate: assert parent is valid and different from n
Date: 2025-04-21 15:34:49
Message-ID: E1u6tAX-0017pz-1E@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

MemoryContextCreate: assert parent is valid and different from node.

The case of "node == parent" might seem impossible, since we just
allocated the new node. But it's possible if parent is a dangling
reference to a recently-deleted context. In fact, given aset.c's
habit of recycling contexts, it's actually rather likely if that's so.
If we'd had this assertion before, it would have simplified debugging
a recently-identified walsender issue.

Reported-by: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/CAO6_XqoJA7-_G6t7Uqe5nWF3nj+QBGn4F6Ptp=rUGDr0zo+KvA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5ec8b01c30e7ea34bb42592ad9d34d4b02ea593d

Modified Files
--------------
src/backend/utils/mmgr/mcxt.c | 4 ++++
1 file changed, 4 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2025-04-21 16:09:41 pgsql: Use the same cmd_context throughout a walsender's lifetime.
Previous Message Fujii Masao 2025-04-21 05:57:12 pgsql: doc: Fix memory context level in pg_log_backend_memory_contexts(