pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Lakhin <exclusion@gmail.com>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Extending outfuncs support to utility statements
Date: Sun, 19 Mar 2023 15:00:01 +0300
Message-ID: <4995256b-cc65-170e-0b22-60ad2cd535f1@gmail.com> (raw)
In-Reply-To: <b4ff5db0-387d-4aea-3f9c-956a068bc503@enterprisedb.com>
References: <4159834.1657405226@sss.pgh.pa.us>
	<9b197806-17ee-acba-0e70-01263aa46e79@enterprisedb.com>
	<1972439.1657665506@sss.pgh.pa.us>
	<2e7adbce-2ff5-866e-8753-9969b0ce332b@enterprisedb.com>
	<20220922153257.r5wj74prdqrucnov@awork3.anarazel.de>
	<1415326.1663863390@sss.pgh.pa.us>
	<1418391.1663865327@sss.pgh.pa.us>
	<20220922170103.6tnwbpzeddceiyyl@awork3.anarazel.de>
	<1944074.1663880234@sss.pgh.pa.us>
	<1946183.1663881687@sss.pgh.pa.us>
	<b4ff5db0-387d-4aea-3f9c-956a068bc503@enterprisedb.com>

Hello,

26.09.2022 17:46, Peter Eisentraut wrote:
> On 22.09.22 23:21, Tom Lane wrote:
>> Anyway, this is a bit far afield from the stated topic of this
>> thread.  I think we should commit something approximately like
>> what I posted and then start a new thread specifically about
>> what we'd like to do about utility commands in new-style SQL
>> functions.
>
> Right, I have committed everything and will close the CF entry.  I don't have a specific idea about how to move 
> forward right now.

Please look at the function _readA_Const() (introduced in a6bc33019), which fails on current master under valgrind:
CPPFLAGS="-DUSE_VALGRIND -DWRITE_READ_PARSE_PLAN_TREES -Og " ./configure -q --enable-debug && make -s -j8 && make check

============== creating temporary instance            ==============
============== initializing database system           ==============

pg_regress: initdb failed
Examine .../src/test/regress/log/initdb.log for the reason.

initdb.log contains:
performing post-bootstrap initialization ... ==00:00:00:02.155 3419654== Invalid read of size 16
==00:00:00:02.155 3419654==    at 0x448691: memcpy (string_fortified.h:29)
==00:00:00:02.155 3419654==    by 0x448691: _readA_Const (readfuncs.c:315)
==00:00:00:02.155 3419654==    by 0x44CCD2: parseNodeString (readfuncs.switch.c:129)
==00:00:00:02.155 3419654==    by 0x4348D6: nodeRead (read.c:338)
==00:00:00:02.155 3419654==    by 0x434879: nodeRead (read.c:452)
==00:00:00:02.155 3419654==    by 0x440E6C: _readTypeName (readfuncs.funcs.c:830)
==00:00:00:02.155 3419654==    by 0x44CC3A: parseNodeString (readfuncs.switch.c:121)
==00:00:00:02.155 3419654==    by 0x4348D6: nodeRead (read.c:338)
==00:00:00:02.155 3419654==    by 0x43D51D: _readFunctionParameter (readfuncs.funcs.c:2513)
==00:00:00:02.155 3419654==    by 0x44DE0C: parseNodeString (readfuncs.switch.c:367)
==00:00:00:02.155 3419654==    by 0x4348D6: nodeRead (read.c:338)
==00:00:00:02.155 3419654==    by 0x434879: nodeRead (read.c:452)
==00:00:00:02.155 3419654==    by 0x438A9C: _readCreateFunctionStmt (readfuncs.funcs.c:2499)
==00:00:00:02.155 3419654==  Address 0xf12f718 is 0 bytes inside a block of size 8 client-defined
==00:00:00:02.155 3419654==    at 0x6A70C3: MemoryContextAllocZeroAligned (mcxt.c:1109)
==00:00:00:02.155 3419654==    by 0x450C31: makeInteger (value.c:25)
==00:00:00:02.155 3419654==    by 0x434D59: nodeRead (read.c:482)
==00:00:00:02.155 3419654==    by 0x448690: _readA_Const (readfuncs.c:313)
==00:00:00:02.155 3419654==    by 0x44CCD2: parseNodeString (readfuncs.switch.c:129)
==00:00:00:02.155 3419654==    by 0x4348D6: nodeRead (read.c:338)
==00:00:00:02.155 3419654==    by 0x434879: nodeRead (read.c:452)
==00:00:00:02.155 3419654==    by 0x440E6C: _readTypeName (readfuncs.funcs.c:830)
==00:00:00:02.155 3419654==    by 0x44CC3A: parseNodeString (readfuncs.switch.c:121)
==00:00:00:02.155 3419654==    by 0x4348D6: nodeRead (read.c:338)
==00:00:00:02.155 3419654==    by 0x43D51D: _readFunctionParameter (readfuncs.funcs.c:2513)
==00:00:00:02.155 3419654==    by 0x44DE0C: parseNodeString (readfuncs.switch.c:367)
==00:00:00:02.155 3419654==

Here _readA_Const() performs:
                 union ValUnion *tmp = nodeRead(NULL, 0);

                 memcpy(&local_node->val, tmp, sizeof(*tmp));

where sizeof(union ValUnion) = 16, but nodeRead()->makeInteger() produced Integer (sizeof(Integer) = 8).

Best regards,
Alexander

view thread (20+ messages)  latest in thread

Message-ID: <4995256b-cc65-170e-0b22-60ad2cd535f1@gmail.com>
Permalink:  ../4995256b-cc65-170e-0b22-60ad2cd535f1@gmail.com/
Also on:    postgresql.org/message-id/4995256b-cc65-170e-0b22-60ad2cd535f1@gmail.com

 · 

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-hackers@postgresql.org
  Cc: exclusion@gmail.com, peter.eisentraut@enterprisedb.com, tgl@sss.pgh.pa.us, andres@anarazel.de, pgsql-hackers@lists.postgresql.org
  Subject: Re: Extending outfuncs support to utility statements
  In-Reply-To: <4995256b-cc65-170e-0b22-60ad2cd535f1@gmail.com>

* 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