Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs - Mailing list pgsql-bugs

From Alexander Lakhin
Subject Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs
Date
Msg-id f6fd313f-a121-cebb-641a-28558490065b@gmail.com
Whole thread Raw
In response to Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs  (Michael Paquier <michael@paquier.xyz>)
Responses Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs  (Michael Paquier <michael@paquier.xyz>)
List pgsql-bugs
Hello Michael,
03.01.2021 08:15, Michael Paquier wrote:
> On Sat, Jan 02, 2021 at 03:00:00PM +0000, PG Bug reporting form wrote:
>> valgrind detects an invalid read:
>> ==00:00:00:04.145 217144== Invalid read of size 8
>> ==00:00:00:04.145 217144==    at 0x302CB7: makeDependencyGraphWalker
>> (parse_cte.c:549)
>> ==00:00:00:04.145 217144==    by 0x302EA1: makeDependencyGraph
>> (parse_cte.c:439)
>> ==00:00:00:04.145 217144==    by 0x304557: transformWithClause
>> (parse_cte.c:176)
>>
>> The first bad commit is 1cff1b95.
> The same kind of list manipulation is done in two places in
> parse_cte.c, and there are extra ones in split_pathtarget_walker().  I
> cannot reproduce that here, and I have just tried with different
> optimization levels on HEAD and REL_13_STABLE.  Are you using specific
> options for valgrind?
I'm using gcc 10.2.0 and valgrind-3.15.0, and building REL_13_STABLE
(c09f6882) with:
CPPFLAGS="-DUSE_VALGRIND -Og" ./configure --enable-debug
--enable-cassert && make -j8
Also I'm using a  patch [1] to inject valgrind into the `make check`
procedure. So it's possible to reproduce the issue with the extended
with.sql:
echo "
WITH RECURSIVE rec(x) AS (

    WITH outermost(x) AS (
      SELECT (
        WITH innermost as (SELECT 1)
        SELECT * FROM innermost
      )
    )
    SELECT * FROM outermost
)
SELECT * FROM rec;
" >>src/test/regress/sql/with.sql
make check

'make check' fails and src/test/regress/log/postmaster.log contains the
aforementioned valgrind message.

If it's still not reproduced for you, please let me know your
OS/compiler/valgrind version and I'll try it in your environment too.

[1]
https://www.postgresql.org/message-id/10dae4a1-e714-601d-7518-c19414255180%40gmail.com

Best regards,
Alexander



pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs
Next
From: Michael Paquier
Date:
Subject: Re: BUG #16801: Invalid memory access on WITH RECURSIVE with nested WITHs