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 1pnjQH-0006Vw-N5 for pgsql-bugs@arkaria.postgresql.org; Sat, 15 Apr 2023 17:10:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pnjQG-0002Ek-Iy for pgsql-bugs@arkaria.postgresql.org; Sat, 15 Apr 2023 17:10:48 +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 1pn06U-0004zO-4y for pgsql-bugs@lists.postgresql.org; Thu, 13 Apr 2023 16:47:22 +0000 Received: from zg8tmtyylji0my4xnjqumte4.icoremail.net ([162.243.164.118]) by magus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1pn06P-002g3S-Fk for pgsql-bugs@lists.postgresql.org; Thu, 13 Apr 2023 16:47:21 +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=AGMr+OQ+RaOiGg4IBIArhZBJdDtQHwxlwXWR91JKQwo=; b=aosb2c20AA+lFZ4neFqM40aGKPRdhDAhreBeETvFO/KxjtaXDOhG311WyFX1ZQ wU8h7iXMnxnA1f3AIZVg8qezdrSB7W+W53JC2ii8gpxGK1mKlX2SIjdBAJMZN+Lm 7Vk1WeYynQR7grjTFs6tZQcId8IQbZp93gMxUv0LxnkW0= Received: from LAPTOPJPQFQS7K (unknown [183.172.66.176]) by web4 (Coremail) with SMTP id ywQGZQCHk20RMjhkpgctEw--.42306S2; Fri, 14 Apr 2023 00:47:13 +0800 (CST) From: To: Cc: , Subject: =?us-ascii?Q?9._PostgreSQL_Server_15.2_Subprocess_Went_down_at_function_'?= =?us-ascii?Q?expanded=5Frecord=5Fset=5Ffields'?= Date: Fri, 14 Apr 2023 00:47:15 +0800 Message-ID: <00dd01d96e27$9a8ca9f0$cfa5fdd0$@mails.tsinghua.edu.cn> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00DE_01D96E6A.A8B0FB60" X-Mailer: Microsoft Outlook 16.0 Content-Language: zh-cn Thread-Index: AdluJ4ieNfpcIr/BTFi8+BpASQKhXA== X-CM-TRANSID: ywQGZQCHk20RMjhkpgctEw--.42306S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXryUWry5Kry8Zw17Cr1UAwb_yoW5Cr1DpF yjyr90krWUGa4v9a17Xr1Y9r1kZFWktry5Gr1xKFy3XayYqFs2gFW8tFWvg3WYgr4jkr1j 9a4IgFy093Z0vaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmYb7Iv0xC_Cr1lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I 8E87Iv6xkF7I0E14v26rxl6s0DM2vYz4IE04k24VAvwVAKI4IrM2AIxVAIcxkEcVAq07x2 0xvEncxIr21l5I8CrVAYj202j2C_Wr0_Ar1l5I8CrVAqjxCE14ACF2xKxwAqx4xG64kEw2 xG04xIwI0_Gr0_Xr1l5I8CrVCF0I0E4I0vr24lYx0E2Ix0cI8IcVAFwI0_JF0_Jw1lYx0E x4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwAKzV CY07xG64k0F24lc2xSY4AK67AK6r1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_ Jr0_Gr1lx2IqxVAqx4xG67AKxVWUGVWUWwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1V AY17CE14v26r1Y6r17MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAI cVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42 IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIev Ja73UjIFyTuYvjxU-9NVUUUUU 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_00DE_01D96E6A.A8B0FB60 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Description: PostgreSQL Server 15.2 Subprocess Went down at function 'expanded_record_set_fields' 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 FUNCTION command(cstring) RETURNS test_extdep_commands AS 'int4in' LANGUAGE internal STRICT IMMUTABLE; CREATE FUNCTION inet_tbl(test_extdep_commands) RETURNS cstring AS 'int4out' LANGUAGE internal STRICT IMMUTABLE; CREATE TYPE test_extdep_commands ( internallength = variable, input = command, output = inet_tbl, alignment = int4, default = 'zippo' ); CREATE TYPE inet_idx3 AS (f1 test_extdep_commands, f2 test_extdep_commands); CREATE FUNCTION _return(x int, y int, z int) RETURNS inet_idx3 AS $$ declare v inet_idx3 := row(x, y); begin v.test_pg_dump_t1 := z; return v; end $$ LANGUAGE plpgsql; SELECT * FROM _return(1,2,0); ``` Backtrace: ``` #0 0x18480e0 (expanded_record_set_fields+0x4a0) #1 0x7f2a94004ae8 (exec_move_row_from_fields+0xe48) #2 0x7f2a93fd703c (exec_move_row+0x7fc) #3 0x7f2a93fd6730 (exec_move_row_from_datum+0x17b0) #4 0x7f2a93fdf4e5 (exec_assign_value+0xed5) #5 0x7f2a93fe0178 (exec_assign_expr+0x408) #6 0x7f2a93fdcaf8 (exec_stmt_block+0x708) #7 0x7f2a93fd7574 (exec_toplevel_block+0x234) #8 0x7f2a93fd1023 (plpgsql_exec_function+0x11f3) #9 0x7f2a9403481f (plpgsql_call_handler+0x86f) #10 0xee3b21 (ExecMakeTableFunctionResult+0xf31) #11 0xf47d9d (FunctionNext+0x37d) #12 0xee8cd0 (ExecScanFetch+0x7d0) #13 0xee8207 (ExecScan+0x107) #14 0xf46b91 (ExecFunctionScan+0x31) #15 0xedbf36 (ExecProcNodeFirst+0x116) #16 0xec0e2c (ExecProcNode+0x7c) #17 0xeb3a9f (ExecutePlan+0x1df) #18 0xeb3780 (standard_ExecutorRun+0x550) #19 0xeb3224 (ExecutorRun+0x64) #20 0x16f6361 (PortalRunSelect+0x241) #21 0x16f53bd (PortalRun+0x7ed) #22 0x16e9694 (exec_simple_query+0xe04) #23 0x16e7a63 (PostgresMain+0x1523) #24 0x144c17b (BackendRun+0xbb) #25 0x144ad85 (BackendStartup+0x525) #26 0x14481e6 (ServerLoop+0x616) #27 0x1443e0f (PostmasterMain+0x30cf) #28 0x106ebf2 (main+0x5a2) #29 0x7f2a9ff94083 (__libc_start_main+0xf3) #30 0x49fc0e (_start+0x2e) ``` ------=_NextPart_000_00DE_01D96E6A.A8B0FB60 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

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

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 = FUNCTION command(cstring)

   = RETURNS test_extdep_commands

   = AS 'int4in'

   = LANGUAGE internal STRICT IMMUTABLE;

CREATE = FUNCTION inet_tbl(test_extdep_commands)

   = RETURNS cstring

   = AS 'int4out'

   = LANGUAGE internal STRICT IMMUTABLE;

 

CREATE TYPE = test_extdep_commands (

   = internallength =3D variable,

   = input =3D command,

   = output =3D inet_tbl,

   = alignment =3D int4,

   = default =3D 'zippo'

);=

CREATE TYPE = inet_idx3 AS (f1 test_extdep_commands, f2 = test_extdep_commands);

CREATE = FUNCTION _return(x int, y int, z int)

  = RETURNS inet_idx3 AS $$

declare v = inet_idx3 :=3D row(x, y);

begin

v.test_pg_dum= p_t1 :=3D z;

return = v;

end

$$ LANGUAGE = plpgsql;

SELECT * = FROM _return(1,2,0);

```

 

Backtrace:

```

#0 0x18480e0 = (expanded_record_set_fields+0x4a0)

#1 = 0x7f2a94004ae8 (exec_move_row_from_fields+0xe48)

#2 = 0x7f2a93fd703c (exec_move_row+0x7fc)

#3 = 0x7f2a93fd6730 (exec_move_row_from_datum+0x17b0)

#4 = 0x7f2a93fdf4e5 (exec_assign_value+0xed5)

#5 = 0x7f2a93fe0178 (exec_assign_expr+0x408)

#6 = 0x7f2a93fdcaf8 (exec_stmt_block+0x708)

#7 = 0x7f2a93fd7574 (exec_toplevel_block+0x234)

#8 = 0x7f2a93fd1023 (plpgsql_exec_function+0x11f3)

#9 = 0x7f2a9403481f (plpgsql_call_handler+0x86f)

#10 0xee3b21 = (ExecMakeTableFunctionResult+0xf31)

#11 0xf47d9d = (FunctionNext+0x37d)

#12 0xee8cd0 = (ExecScanFetch+0x7d0)

#13 0xee8207 = (ExecScan+0x107)

#14 0xf46b91 = (ExecFunctionScan+0x31)

#15 0xedbf36 = (ExecProcNodeFirst+0x116)

#16 0xec0e2c = (ExecProcNode+0x7c)

#17 0xeb3a9f = (ExecutePlan+0x1df)

#18 0xeb3780 = (standard_ExecutorRun+0x550)

#19 0xeb3224 = (ExecutorRun+0x64)

#20 = 0x16f6361 (PortalRunSelect+0x241)

#21 = 0x16f53bd (PortalRun+0x7ed)

#22 = 0x16e9694 (exec_simple_query+0xe04)

#23 = 0x16e7a63 (PostgresMain+0x1523)

#24 = 0x144c17b (BackendRun+0xbb)

#25 = 0x144ad85 (BackendStartup+0x525)

#26 = 0x14481e6 (ServerLoop+0x616)

#27 = 0x1443e0f (PostmasterMain+0x30cf)

#28 = 0x106ebf2 (main+0x5a2)

#29 = 0x7f2a9ff94083 (__libc_start_main+0xf3)

#30 0x49fc0e = (_start+0x2e)

```

 

------=_NextPart_000_00DE_01D96E6A.A8B0FB60--