pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix list-manipulation bug in WITH RECURSIVE processing.
Date: Fri, 26 Feb 2021 01:47:44 +0000
Message-ID: <E1lFSEK-0007v7-Jq@gemulon.postgresql.org> (raw)

Fix list-manipulation bug in WITH RECURSIVE processing.

makeDependencyGraphWalker and checkWellFormedRecursionWalker
thought they could hold onto a pointer to a list's first
cons cell while the list was modified by recursive calls.
That was okay when the cons cell was actually separately
palloc'd ... but since commit 1cff1b95a, it's quite unsafe,
leading to core dumps or incorrect complaints of faulty
WITH nesting.

In the field this'd require at least a seven-deep WITH nest
to cause an issue, but enabling DEBUG_LIST_MEMORY_USAGE
allows the bug to be seen with lesser nesting depths.

Per bug #16801 from Alexander Lakhin.  Back-patch to v13.

Michael Paquier and Tom Lane

Discussion: https://postgr.es/m/16801-393c7922143eaa4d@postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/49076fd3ba6ba7cda2ac16d9aaf554025f0bba2b

Modified Files
--------------
src/backend/parser/parse_cte.c     | 12 ++++----
src/test/regress/expected/with.out | 59 ++++++++++++++++++++++++++++++++++++++
src/test/regress/sql/with.sql      | 44 ++++++++++++++++++++++++++++
3 files changed, 109 insertions(+), 6 deletions(-)



view thread (2+ messages)

Message-ID: <E1lFSEK-0007v7-Jq@gemulon.postgresql.org>
Permalink:  ../E1lFSEK-0007v7-Jq@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1lFSEK-0007v7-Jq@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix list-manipulation bug in WITH RECURSIVE processing.
  In-Reply-To: <E1lFSEK-0007v7-Jq@gemulon.postgresql.org>
  References: <E1lFSEK-0007v7-Jq@gemulon.postgresql.org>

* 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