pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Alexander Lakhin <exclusion@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs
Date: Wed, 24 Feb 2021 21:13:46 -0500
Message-ID: <51877.1614219226@sss.pgh.pa.us> (raw)
In-Reply-To: <YDb9wdB1GUkr+NAD@paquier.xyz>
References: <16801-393c7922143eaa4d@postgresql.org>
	<X/FTDocQD3D7+aIJ@paquier.xyz>
	<eb358b3f-8272-d0a9-6645-983e7ad2bec4@gmail.com>
	<YDXeLBqjDeQQPGoO@paquier.xyz>
	<4057243.1614179963@sss.pgh.pa.us>
	<31724.1614213386@sss.pgh.pa.us>
	<YDb9wdB1GUkr+NAD@paquier.xyz>

Michael Paquier <michael@paquier.xyz> writes:
> Yes, thanks.  While looking at that this morning, I have been able to
> get a crash with my previous patch once I used more nesting in those
> CTEs and your test is much simpler.  I also got a test case able to
> break things the same way in checkWellFormedRecursionWalker():

> WITH RECURSIVE outermost(x) AS (
>   SELECT 1
>   UNION (WITH innermost as (WITH innermost2 AS (SELECT 2) SELECT * FROM innermost2)
>          SELECT * FROM outermost
>          UNION SELECT * FROM innermost)
> )
> SELECT * FROM outermost ORDER BY 1;

Hmm, I don't see any failure from that...

In my understanding of the bug, you need at least half a dozen levels of
WITH nesting to provoke a problem, because nothing will go wrong until the
innerwiths list gets to be six entries long, causing list.c to move its
elements array to somewhere else.  If it is possible to fail without that
then there's still something here that I don't get.

			regards, tom lane





view thread (18+ messages)  latest in thread

Message-ID: <51877.1614219226@sss.pgh.pa.us>
Permalink:  ../51877.1614219226@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/51877.1614219226@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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, michael@paquier.xyz, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs
  In-Reply-To: <51877.1614219226@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