Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pnjMF-0006I7-GH for pgsql-bugs@arkaria.postgresql.org; Sat, 15 Apr 2023 17:06:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pnjME-000155-9H for pgsql-bugs@arkaria.postgresql.org; Sat, 15 Apr 2023 17:06:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pmzo9-0001zQ-8L for pgsql-bugs@lists.postgresql.org; Thu, 13 Apr 2023 16:28:25 +0000 Received: from zg8tmtyylji0my4xnjqumte4.icoremail.net ([162.243.164.118]) by magus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1pmzo4-002fsq-Ac for pgsql-bugs@lists.postgresql.org; Thu, 13 Apr 2023 16:28:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mails.tsinghua.edu.cn; s=dkim; h=Received:From:To:Cc:Subject: Date:Message-ID:MIME-Version:Content-Type:Content-Language: Thread-Index; bh=SsEdvpgmI3VhO1JUy/dp7VcuIGo2YpfgNydwhQ2zfU4=; b=Z6ouGYHQYjPrk29bkY1Oi6oWmNHRP3aK6gk1Fmr6UY1jPWSzdfwd7yqnLrx2wc 9g+eVcvnIlPJg7YA8969G8uLCoMV/q1/nGzXHLb0sJLO8+W2PQP961lqznHn8+id NqtAtYBsbyk78gZdRSdIKeBCTf3MAMZSRGSGAqvc/DfyM= Received: from LAPTOPJPQFQS7K (unknown [183.172.66.176]) by web5 (Coremail) with SMTP id zAQGZQDXDN2fLThkMoXXEg--.10240S2; Fri, 14 Apr 2023 00:28:15 +0800 (CST) From: To: Cc: , Subject: =?us-ascii?Q?2._PostgreSQL_Server_Subprocess_Went_down_at_function_'datum?= =?us-ascii?Q?Transfer'?= Date: Fri, 14 Apr 2023 00:28:18 +0800 Message-ID: <008201d96e24$f49035f0$ddb0a1d0$@mails.tsinghua.edu.cn> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0083_01D96E68.02B46050" X-Mailer: Microsoft Outlook 16.0 Content-Language: zh-cn Thread-Index: AdluJN/P6DxluGdVS566B1hFPvJWcw== X-CM-TRANSID: zAQGZQDXDN2fLThkMoXXEg--.10240S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXryUWry5Kry8Zw17Cr1UAwb_yoW5GF1UpF Wqyrn8AFZ7Xry0vrs29r40q3ykZayDtry5Wr97KFy3Xay3Xr4vga4jvay29a1YkrZ7Cr1r Aa47A34v93Z8Ww7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUm0b7Iv0xC_Cr1lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I 8E87Iv6xkF7I0E14v26rxl6s0DM2vYz4IE04k24VAvwVAKI4IrM2AIxVAIcxkEcVAq07x2 0xvEncxIr21l5I8CrVAYj202j2C_Wr0_Ar1l5I8CrVAqjxCE14ACF2xKxwAqx4xG64kEw2 xG04xIwI0_Gr0_Xr1l5I8CrVCF0I0E4I0vr24lYx0E2Ix0cI8IcVAFwI0_Jrv_JF1lYx0E x4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwAKzV CY07xG64k0F24lc2xSY4AK67AK6r1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_ Jr0_Gr1lx2IqxVAqx4xG67AKxVWUGVWUWwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1V AY17CE14v26r1Y6r17MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAI cVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42 IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVj vjDU0xZFpf9x07jkF4_UUUUU= X-CM-SenderInfo: him2jjo6pdxz3vow2x5qjk3toohg3hdfq/ List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multipart message in MIME format. ------=_NextPart_000_0083_01D96E68.02B46050 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Description: PostgreSQL Server Subprocess Went down at function 'datumTransfer' PostgreSQL Server Version: PostgreSQL 15.2 on x86_64-pc-linux-gnu, compiled by Ubuntu clang version 12.0.1, 64-bit Discoverer: Jingzhou Fu, Jie Liang and Zhiyong Wu in WingTecher Lab of Tsinghua University and Shuimuyulin ltd Email address: fjz22@mails.tsinghua.edu.cn , wuzy21@mails.tsinghua.edu.cn , ljiee@mail.tsinghua.edu.cn Way to Reproduce with Docker (write the poc content into file PoC.sql): ```bash docker container rm some-postgres -f docker run --name some-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres:15.2 sleep 5 # wait the server start . docker exec -i some-postgres psql --user=postgres < PoC.sql # Output: # server closed the connection unexpectedly # This probably means the server terminated abnormally # before or while processing the request. # connection to server was lost ``` PoC: ```sql CREATE TYPE foo; CREATE FUNCTION bar(foo) RETURNS cstring AS 'int4out' LANGUAGE internal STRICT IMMUTABLE; CREATE FUNCTION box_tbl(cstring) RETURNS foo AS 'boolin' LANGUAGE internal IMMUTABLE STRICT; CREATE TYPE foo(INPUT = box_tbl, OUTPUT = bar); do $$ declare r foo; begin for r in values (1,2),(3,4),(6,5) loop raise notice 'r = %', r; end loop; end$$; ``` Backtrace: ``` #0 0x1831798 (datumTransfer+0x68) #1 0x7f09381c4e5e (exec_assign_value+0x84e) #2 0x7f09381eb04c (exec_move_row_from_fields+0x13ac) #3 0x7f09381bd03c (exec_move_row+0x7fc) #4 0x7f09381df6bd (exec_for_query+0x92d) #5 0x7f09381d124b (exec_stmt_fors+0x15b) #6 0x7f09381c6fa0 (exec_stmts+0x910) #7 0x7f09381c41d2 (exec_stmt_block+0x1de2) #8 0x7f09381bd574 (exec_toplevel_block+0x234) #9 0x7f09381b7023 (plpgsql_exec_function+0x11f3) #10 0x7f093821b3dd (plpgsql_inline_handler+0x83d) #11 0x1cc01da (FunctionCall1Coll+0x3ca) #12 0x1cc4e45 (OidFunctionCall1Coll+0x105) #13 0xcb357d (ExecuteDoStmt+0xecd) #14 0x16fb7b0 (standard_ProcessUtility+0x1190) #15 0x16fa617 (ProcessUtility+0xa7) #16 0x16f9667 (PortalRunUtility+0x2a7) #17 0x16f7606 (PortalRunMulti+0xa96) #18 0x16f559b (PortalRun+0x9cb) #19 0x16e9694 (exec_simple_query+0xe04) #20 0x16e7a63 (PostgresMain+0x1523) #21 0x144c17b (BackendRun+0xbb) #22 0x144ad85 (BackendStartup+0x525) #23 0x14481e6 (ServerLoop+0x616) #24 0x1443e0f (PostmasterMain+0x30cf) #25 0x106ebf2 (main+0x5a2) #26 0x7f094417a083 (__libc_start_main+0xf3) #27 0x49fc0e (_start+0x2e)``` ------=_NextPart_000_0083_01D96E68.02B46050 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Description: = PostgreSQL Server Subprocess Went down at function = ‘datumTransfer’

PostgreSQL = Server Version: PostgreSQL 15.2 on x86_64-pc-linux-gnu, compiled by = Ubuntu clang version 12.0.1, 64-bit

Discoverer: = Jingzhou Fu, Jie Liang and Zhiyong Wu in WingTecher Lab of Tsinghua = University and Shuimuyulin ltd

Email = address: fjz22@mails.tsinghua.edu.cn  ,   wuzy21@mails.tsinghua.edu.cn&n= bsp; ,  = ljiee@mail.tsinghua.edu.cn

 

Way to = Reproduce with Docker (write the poc content into file = PoC.sql):

```bash<= /o:p>

docker = container rm some-postgres -f

docker run = --name some-postgres -p 5432:5432 -e = POSTGRES_PASSWORD=3Dmysecretpassword -d = postgres:15.2

 

sleep 5 # = wait the server start …

 

docker exec = -i some-postgres psql --user=3Dpostgres < = PoC.sql

 

# = Output:

# =   server closed the connection = unexpectedly

# =          This probably = means the server terminated abnormally

# =          before or while = processing the request.

# =   connection to server was lost

```

 

PoC:

```sql

CREATE TYPE = foo;

CREATE = FUNCTION bar(foo)

   = RETURNS cstring

   = AS 'int4out'

   = LANGUAGE internal STRICT IMMUTABLE;

CREATE = FUNCTION box_tbl(cstring) RETURNS foo AS = 'boolin'

  &= nbsp; LANGUAGE internal IMMUTABLE STRICT;

CREATE TYPE = foo(INPUT =3D box_tbl, OUTPUT =3D bar);

do = $$

declare r = foo;

begin

  for r = in values (1,2),(3,4),(6,5) loop

  &= nbsp; raise notice 'r =3D %', r;

  end = loop;

end$$;

```

 

Backtrace:

```

#0 0x1831798 = (datumTransfer+0x68)

#1 = 0x7f09381c4e5e (exec_assign_value+0x84e)

#2 = 0x7f09381eb04c = (exec_move_row_from_fields+0x13ac)

#3 = 0x7f09381bd03c (exec_move_row+0x7fc)

#4 = 0x7f09381df6bd (exec_for_query+0x92d)

#5 = 0x7f09381d124b (exec_stmt_fors+0x15b)

#6 = 0x7f09381c6fa0 (exec_stmts+0x910)

#7 = 0x7f09381c41d2 (exec_stmt_block+0x1de2)

#8 = 0x7f09381bd574 (exec_toplevel_block+0x234)

#9 = 0x7f09381b7023 (plpgsql_exec_function+0x11f3)

#10 = 0x7f093821b3dd (plpgsql_inline_handler+0x83d)

#11 = 0x1cc01da (FunctionCall1Coll+0x3ca)

#12 = 0x1cc4e45 (OidFunctionCall1Coll+0x105)

#13 0xcb357d = (ExecuteDoStmt+0xecd)

#14 = 0x16fb7b0 (standard_ProcessUtility+0x1190)

#15 = 0x16fa617 (ProcessUtility+0xa7)

#16 = 0x16f9667 (PortalRunUtility+0x2a7)

#17 = 0x16f7606 (PortalRunMulti+0xa96)

#18 = 0x16f559b (PortalRun+0x9cb)

#19 = 0x16e9694 (exec_simple_query+0xe04)

#20 = 0x16e7a63 (PostgresMain+0x1523)

#21 = 0x144c17b (BackendRun+0xbb)

#22 = 0x144ad85 (BackendStartup+0x525)

#23 = 0x14481e6 (ServerLoop+0x616)

#24 = 0x1443e0f (PostmasterMain+0x30cf)

#25 = 0x106ebf2 (main+0x5a2)

#26 = 0x7f094417a083 (__libc_start_main+0xf3)

#27 0x49fc0e = (_start+0x2e)```

 

------=_NextPart_000_0083_01D96E68.02B46050--