8. PostgreSQL Server 15.2 Subprocess Went down at function 'pg_detoast_datum_copy'

From: <fjz22(at)mails(dot)tsinghua(dot)edu(dot)cn>
To: <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Cc: <ljiee(at)mail(dot)tsinghua(dot)edu(dot)cn>, <wuzy21(at)mails(dot)tsinghua(dot)edu(dot)cn>
Subject: 8. PostgreSQL Server 15.2 Subprocess Went down at function 'pg_detoast_datum_copy'
Date: 2023-04-13 16:45:43
Message-ID: 00d001d96e27$63514270$29f3c750$@mails.tsinghua.edu.cn
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Description: PostgreSQL Server 15.2 Subprocess Went down at function
'pg_detoast_datum_copy'

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(at)mails(dot)tsinghua(dot)edu(dot)cn , wuzy21(at)mails(dot)tsinghua(dot)edu(dot)cn
, ljiee(at)mail(dot)tsinghua(dot)edu(dot)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 tidrangescan(cstring) returns tidrangescan

strict immutable language internal as 'int8in';

CREATE FUNCTION f2(tidrangescan)

RETURNS cstring

AS 'textout'

LANGUAGE internal STRICT IMMUTABLE;

CREATE TYPE tidrangescan (

internallength = variable,

input = tidrangescan,

output = f2,

alignment = int4

);

CREATE CAST (int4 AS tidrangescan) WITH INOUT;

SELECT 1234::int4::tidrangescan;

```

Backtrace:

```

#0 0x1cba709 (pg_detoast_datum_copy+0x49)

#1 0x1358622 (evaluate_expr+0x322)

#2 0x135d9c5 (evaluate_function+0xd95)

#3 0x135b521 (simplify_function+0x431)

#4 0x134eb33 (eval_const_expressions_mutator+0x5773)

#5 0x111caaf (expression_tree_mutator+0x2daf)

#6 0x1355114 (eval_const_expressions_mutator+0xbd54)

#7 0x111d808 (expression_tree_mutator+0x3b08)

#8 0x1355114 (eval_const_expressions_mutator+0xbd54)

#9 0x1349343 (eval_const_expressions+0x2a3)

#10 0x12a5900 (preprocess_expression+0xf0)

#11 0x12a0186 (subquery_planner+0x1b66)

#12 0x129ba27 (standard_planner+0xbc7)

#13 0x129ae4c (planner+0x5c)

#14 0x16e1e66 (pg_plan_query+0xf6)

#15 0x16e2862 (pg_plan_queries+0x8a2)

#16 0x16e924d (exec_simple_query+0x9bd)

#17 0x16e7a63 (PostgresMain+0x1523)

#18 0x144c17b (BackendRun+0xbb)

#19 0x144ad85 (BackendStartup+0x525)

#20 0x14481e6 (ServerLoop+0x616)

#21 0x1443e0f (PostmasterMain+0x30cf)

#22 0x106ebf2 (main+0x5a2)

#23 0x7f98389dc083 (__libc_start_main+0xf3)

#24 0x49fc0e (_start+0x2e)

```

Browse pgsql-bugs by date

  From Date Subject
Next Message fjz22 2023-04-13 16:47:15 9. PostgreSQL Server 15.2 Subprocess Went down at function 'expanded_record_set_fields'
Previous Message fjz22 2023-04-13 16:43:40 7. PostgreSQL Server 15.2 (ASAN Enabled) Subprocess Went down at Function 'heap_form_tuple'