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 1pnjLx-0006Gf-G5 for pgsql-bugs@arkaria.postgresql.org; Sat, 15 Apr 2023 17:06:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pnjLu-0006gS-AM for pgsql-bugs@arkaria.postgresql.org; Sat, 15 Apr 2023 17:06:18 +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 1pmzhV-00074f-1b for pgsql-bugs@lists.postgresql.org; Thu, 13 Apr 2023 16:21:34 +0000 Received: from azure-sdnproxy.icoremail.net ([20.228.234.168]) by magus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1pmzhM-002fpS-5q for pgsql-bugs@lists.postgresql.org; Thu, 13 Apr 2023 16:21:30 +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=nLEoQASljIZ9b/IY2/F8/02MDaj07V57qnutij8C2A8=; b=TkCaW5/MXWNJ5Uh8E5s+olD8/4eOdE8yijdDmlLWHtSqVsKuvSl1vVcnpX9D+2 jhWf0NGbn9zQhsWj6OlQ31B3bow0SE3ogznj/7LRVCH//kmxq9JdpwYBMTTMfH+h XTPYxzBLp3FUVrXHJ9w4Yrhd9UyfGPhX8EOk6CQUaMLug= Received: from LAPTOPJPQFQS7K (unknown [183.172.66.176]) by web2 (Coremail) with SMTP id yQQGZQC3D478Kzhka4H+Eg--.53737S2; Fri, 14 Apr 2023 00:21:16 +0800 (CST) From: To: Cc: , Subject: =?us-ascii?Q?1._PostgreSQL_Server_Subprocess_Went_down_at_function_'pg=5F?= =?us-ascii?Q?detoast=5Fdatum=5Fpacked'?= Date: Fri, 14 Apr 2023 00:21:19 +0800 Message-ID: <007201d96e23$fabaff10$f030fd30$@mails.tsinghua.edu.cn> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0073_01D96E67.08DF7790" X-Mailer: Microsoft Outlook 16.0 Content-Language: zh-cn Thread-Index: AdluI+uDtbNrNR6qS1CUj1EOrkJe5Q== X-CM-TRANSID: yQQGZQC3D478Kzhka4H+Eg--.53737S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXryUWry5Kry8Zw17Cr1UAwb_yoW5GFWkpF yDtF90ya17X3y0qws2vryUurWkAan7Ary5Grn7trySva1UXw4v939FkrZYg3ZakF4kuw1Y va4jka9293Wq937anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUm0b7Iv0xC_Cr1lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I 8E87Iv6xkF7I0E14v26rxl6s0DM2vYz4IE04k24VAvwVAKI4IrM2AIxVAIcxkEcVAq07x2 0xvEncxIr21l5I8CrVAYj202j2C_Wr0_Ar1l5I8CrVAqjxCE14ACF2xKxwAqx4xG64kEw2 xG04xIwI0_Gr0_Xr1l5I8CrVCF0I0E4I0vr24lYx0E2Ix0cI8IcVAFwI0_JrI_JrylYx0E x4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwAKzV CY07xG64k0F24lc2xSY4AK67AK6r1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_ Jr0_Gr1lx2IqxVAqx4xG67AKxVWUGVWUWwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1V AY17CE14v26r1Y6r17MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAI cVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42 IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVj vjDU0xZFpf9x07jDJ5OUUUUU= 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_0073_01D96E67.08DF7790 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Description: PostgreSQL Server Subprocess Went down at function 'pg_detoast_datum_packed' 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 bt_name_heap(cstring) RETURNS committs_test AS 'textin' LANGUAGE internal STRICT IMMUTABLE; CREATE FUNCTION random(committs_test) RETURNS cstring AS 'textout' LANGUAGE internal STRICT IMMUTABLE; CREATE TYPE committs_test ( internallength = 4, input = bt_name_heap, output = random, alignment = int4, default = 42, passedbyvalue ); CREATE TABLE seqno (bt_txt_heap committs_test, bt_f8_heap committs_test); INSERT INTO seqno DEFAULT VALUES; CREATE TYPE committs_test ( "Internallength" = 4, "Input" = bt_name_heap, "Output" = random, "Alignment" = int4, "Default" = 42, "Passedbyvalue" ); CREATE TYPE bt_name_index AS (f1 committs_test, f2 committs_test); CREATE FUNCTION get_default_test() RETURNS SETOF bt_name_index AS ' SELECT * FROM seqno; ' LANGUAGE SQL; SELECT * FROM get_default_test(); ``` Backtrace: ``` #0 0x1cc7669 (pg_detoast_datum_packed+0x49) #1 0x1bd15e9 (text_to_cstring+0x29) #2 0x1bd5516 (textout+0x46) #3 0x1cc01da (FunctionCall1Coll+0x3ca) #4 0x1cc65ff (OutputFunctionCall+0x1f) #5 0x59c7f6 (printtup+0x406) #6 0xeb3bdf (ExecutePlan+0x31f) #7 0xeb3780 (standard_ExecutorRun+0x550) #8 0xeb3224 (ExecutorRun+0x64) #9 0x16f6361 (PortalRunSelect+0x241) #10 0x16f53bd (PortalRun+0x7ed) #11 0x16e9694 (exec_simple_query+0xe04) #12 0x16e7a63 (PostgresMain+0x1523) #13 0x144c17b (BackendRun+0xbb) #14 0x144ad85 (BackendStartup+0x525) #15 0x14481e6 (ServerLoop+0x616) #16 0x1443e0f (PostmasterMain+0x30cf) #17 0x106ebf2 (main+0x5a2) #18 0x7f110a910083 (__libc_start_main+0xf3) #19 0x49fc0e (_start+0x2e) ``` ------=_NextPart_000_0073_01D96E67.08DF7790 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

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

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 bt_name_heap(cstring)

  =  RETURNS committs_test

  =  AS 'textin'

  =  LANGUAGE internal STRICT IMMUTABLE;

CREATE = FUNCTION random(committs_test)

  =  RETURNS cstring

  =  AS 'textout'

  =  LANGUAGE internal STRICT IMMUTABLE;

CREATE TYPE = committs_test (

  =  internallength =3D 4,

  =  input =3D bt_name_heap,

  =  output =3D random,

  =  alignment =3D int4,

  =  default =3D 42,

  =  passedbyvalue

);=

CREATE TABLE = seqno (bt_txt_heap committs_test, bt_f8_heap = committs_test);

INSERT INTO = seqno DEFAULT VALUES;

CREATE TYPE = committs_test (

  =  "Internallength" =3D 4,

  =  "Input" =3D bt_name_heap,

  =  "Output" =3D random,

  =  "Alignment" =3D int4,

  =  "Default" =3D 42,

  =  "Passedbyvalue"

);=

CREATE TYPE = bt_name_index AS (f1 committs_test, f2 = committs_test);

CREATE = FUNCTION get_default_test() RETURNS SETOF bt_name_index AS = '

  = SELECT * FROM seqno;

' LANGUAGE = SQL;

SELECT * = FROM get_default_test();

```

 

Backtrace:

```

#0 0x1cc7669 = (pg_detoast_datum_packed+0x49)

#1 0x1bd15e9 = (text_to_cstring+0x29)

#2 0x1bd5516 = (textout+0x46)

#3 0x1cc01da = (FunctionCall1Coll+0x3ca)

#4 0x1cc65ff = (OutputFunctionCall+0x1f)

#5 0x59c7f6 = (printtup+0x406)

#6 0xeb3bdf = (ExecutePlan+0x31f)

#7 0xeb3780 = (standard_ExecutorRun+0x550)

#8 0xeb3224 = (ExecutorRun+0x64)

#9 0x16f6361 = (PortalRunSelect+0x241)

#10 = 0x16f53bd (PortalRun+0x7ed)

#11 = 0x16e9694 (exec_simple_query+0xe04)

#12 = 0x16e7a63 (PostgresMain+0x1523)

#13 = 0x144c17b (BackendRun+0xbb)

#14 = 0x144ad85 (BackendStartup+0x525)

#15 = 0x14481e6 (ServerLoop+0x616)

#16 = 0x1443e0f (PostmasterMain+0x30cf)

#17 = 0x106ebf2 (main+0x5a2)

#18 = 0x7f110a910083 (__libc_start_main+0xf3)

#19 0x49fc0e = (_start+0x2e)

```

 

------=_NextPart_000_0073_01D96E67.08DF7790--