Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alexander Lakhin <exclusion(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs
Date: 2021-02-26 01:17:50
Message-ID: YDhMPvDL4iLP6gLo@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Feb 25, 2021 at 10:19:43AM -0500, Tom Lane wrote:
> For me, the example I gave fails in a non-debug build. With the code as
> of HEAD, I get "ERROR: stack depth limit exceeded" or a segfault. With
> your patch applied, it complains about w6 not having the correct form for
> a recursive CTE.

Yes, same here for the test stressing makeDependencyGraphWalker().

The second test I posted for checkWellFormedRecursionWalker() passes
on HEAD in a non-debug build, and triggers an assertion with debug
builds. So the second test requires CLOBBER_FREED_MEMORY but not
DEBUG_LIST_MEMORY_USAGE. That's not as good as the first one, but I
would vote for having this second test than none to stress more the
list handling when looking after invalid self-references in a CTE.
This gives me the attached.

I would rather have both tests in the version committed, but if you
think that this addition is not necessary I won't fight hard either :)
--
Michael

Attachment Content-Type Size
bug-16801-fix-v2.patch text/x-diff 4.7 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2021-02-26 01:31:26 Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs
Previous Message Tom Lane 2021-02-25 21:40:32 Re: BUG #16897: gssenc request slow connection