pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Zu-Ming Jiang <zuming.jiang@inf.ethz.ch>
To: pgsql-bugs@lists.postgresql.org
Subject: Server closed the connection unexpectedly
Date: Thu, 15 Jun 2023 18:26:13 +0200
Message-ID: <db03c582-086d-e7cd-d4a1-3bc722f81765@inf.ethz.ch> (raw)

My fuzzer finds a bug in Postgres, which makes the connection closed 
unexpectedly.

--- Steps to reproduce the bug ---
1. /usr/local/pgsql/bin/psql -d postgres -c "drop database redb";
2. /usr/local/pgsql/bin/psql -d postgres -c "create database redb";
3. /usr/local/pgsql/bin/psql -d redb -f pg_testdb10_bk.sql;
4. /usr/local/pgsql/bin/psql -d redb -f unexpected.sql

pg_testdb10_bk.sql and unexpected.sql are attached.

--- Expected behavior ---
No error triggered.

--- Actual behavior ---
The test case makes the connection closed unexpectedly:

psql:unexpected.sql:39: server closed the connection unexpectedly
         This probably means the server terminated abnormally
         before or while processing the request.
psql:unexpected.sql:39: error: connection to server was lost


--- Postgres version ---
Github commit: 3f1aaaa180689f2015e7f7bd01c9be6d7a993b42
Version: PostgreSQL 16beta1 on x86_64-pc-linux-gnu, compiled by gcc 
(Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit

--- Platform information ---
Platform: Ubuntu 20.04
Kernel: Linux 5.4.0-147-generic

Attachments:

pg_testdb10_bk.sql (text/plain, 10.1K) download -- -- PostgreSQL database dump -- -- Dumped from database version 16beta1 -- Dumped by pg_dump version 16beta1 SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies = false; SET xmloption = content; SET client_min_messages = warning; SET row_security = off; SET default_tablespace = ''; SET default_table_access_method = heap; -- -- Name: t0; Type: TABLE; Schema: public; Owner: zuming -- CREATE TABLE public.t0 ( vkey integer, pkey integer, c0 text, c1 integer NOT NULL, c2 text, c3 text ); ALTER TABLE public.t0 OWNER TO zuming; -- -- Name: t1; Type: TABLE; Schema: public; Owner: zuming -- CREATE TABLE public.t1 ( vkey integer, pkey integer NOT NULL, c4 text, c5 text ); ALTER TABLE public.t1 OWNER TO zuming; -- -- Name: t2; Type: TABLE; Schema: public; Owner: zuming -- CREATE TABLE public.t2 ( vkey integer, pkey integer, c6 integer, c7 timestamp without time zone, c8 timestamp without time zone, c9 double precision, c10 double precision, c11 integer, c12 integer, c13 integer, c14 integer ); ALTER TABLE public.t2 OWNER TO zuming; -- -- Name: t3; Type: TABLE; Schema: public; Owner: zuming -- CREATE TABLE public.t3 ( vkey integer, pkey integer, c15 timestamp without time zone, c16 integer, c17 integer, c18 timestamp without time zone, c19 double precision ); ALTER TABLE public.t3 OWNER TO zuming; -- -- Name: t4; Type: VIEW; Schema: public; Owner: zuming -- CREATE VIEW public.t4 AS SELECT c_0 FROM ( SELECT (true AND ((ref_0.c11 IS NOT NULL) AND (( SELECT t0.c0 FROM public.t0 ORDER BY t0.c0 OFFSET 3 LIMIT 1) < ( SELECT t0.c0 FROM public.t0 ORDER BY t0.c0 OFFSET 4 LIMIT 1)))) AS c_0 FROM (public.t2 ref_0 CROSS JOIN public.t2 ref_1) WHERE (ref_1.c8 >= ( SELECT t2.c7 FROM public.t2 ORDER BY t2.c7 OFFSET 4 LIMIT 1))) subq_0 WHERE (COALESCE( CASE WHEN (NOT NULL::boolean) THEN ( SELECT var_pop(t3.c19) AS var_pop FROM public.t3) ELSE ((log(57.49))::double precision * ( SELECT t3.c19 FROM public.t3 ORDER BY t3.c19 OFFSET 4 LIMIT 1)) END, ( SELECT t2.c9 FROM public.t2 ORDER BY t2.c9 OFFSET 4 LIMIT 1)) = NULLIF(NULLIF(( SELECT t2.c9 FROM public.t2 ORDER BY t2.c9 OFFSET 1 LIMIT 1), (NULL::double precision ^ date_part(( SELECT t0.c0 FROM public.t0 ORDER BY t0.c0 OFFSET 97 LIMIT 1), ( SELECT t2.c7 FROM public.t2 ORDER BY t2.c7 OFFSET 4 LIMIT 1)))), power(( SELECT t3.c19 FROM public.t3 ORDER BY t3.c19 OFFSET 3 LIMIT 1), NULL::double precision))); ALTER VIEW public.t4 OWNER TO zuming; -- -- Name: t5; Type: TABLE; Schema: public; Owner: zuming -- CREATE TABLE public.t5 ( vkey integer, pkey integer, c20 double precision NOT NULL, c21 integer, c22 double precision, c23 integer, c24 timestamp without time zone, c25 integer ); ALTER TABLE public.t5 OWNER TO zuming; -- -- Name: t6; Type: TABLE; Schema: public; Owner: zuming -- CREATE TABLE public.t6 ( vkey integer, pkey integer, c26 integer, c27 double precision, c28 integer, c29 double precision, c30 timestamp without time zone, c31 double precision, c32 double precision, c33 text, c34 timestamp without time zone ); ALTER TABLE public.t6 OWNER TO zuming; -- -- Name: t7; Type: VIEW; Schema: public; Owner: zuming -- CREATE VIEW public.t7 AS SELECT ( SELECT min(t6.vkey) AS min FROM public.t6) AS c_0, length(ref_0.c4) AS c_1 FROM ((public.t1 ref_0 FULL JOIN public.t0 ref_1 ON ((ref_0.c4 = ref_1.c0))) FULL JOIN public.t0 ref_2 ON ((ref_0.c5 = ref_2.c0))) WHERE (ref_1.c0 > ( SELECT ref_1.c2 AS c_0 FROM (public.t3 ref_3 RIGHT JOIN public.t0 ref_4 ON ((ref_3.pkey = ref_4.vkey))) WHERE false ORDER BY ref_1.c2 LIMIT 1)) ORDER BY ( SELECT min(t6.vkey) AS min FROM public.t6), (length(ref_0.c4)) LIMIT 85; ALTER VIEW public.t7 OWNER TO zuming; -- -- Data for Name: t0; Type: TABLE DATA; Schema: public; Owner: zuming -- COPY public.t0 (vkey, pkey, c0, c1, c2, c3) FROM stdin; 16 26000 $O 0 9#MQ Jzs&, 23 33000 V*+ -32 4IO gYGUY 27 37000 45 (u #gg.= 28 38000 j7$> -74 \N 50 60000 XE 74 5# Nh&Lb 52 62000 \N -48 sH Z!j3 55 65000 ai` 47 0g WK}C 81 91000 \N -15 ^kOT ? \. -- -- Data for Name: t1; Type: TABLE DATA; Schema: public; Owner: zuming -- COPY public.t1 (vkey, pkey, c4, c5) FROM stdin; 1 11000 AG \N 11 21000 \N 15 25000 }O0L9 KI4 18 28000 cX+=} ,@XF 21 31000 iB L] 30 40000 ]@=$ $ 32 42000 SKLx Y3 33 43000 5IQ ~9?A~ 34 44000 35 45000 \N 7 37 47000 QvY[ c 41 51000 \N RL 53 63000 LWP` X@KkT 58 68000 I \N 59 69000 -] E(c4R 63 73000 (&- rai 66 76000 T^ZwG 8 67 77000 !QoE <do{ 69 79000 -Jp |!1 70 80000 C.E . B 76 86000 2 (8 91 101000 BI X 98 108000 DC7u ~- 99 109000 9 \N \. -- -- Data for Name: t2; Type: TABLE DATA; Schema: public; Owner: zuming -- COPY public.t2 (vkey, pkey, c6, c7, c8, c9, c10, c11, c12, c13, c14) FROM stdin; 2 12000 0 2055-01-04 23:40:00 2024-07-22 23:03:49 0 \N 27 60 56 -92 5 15000 0 2000-09-25 22:52:05 2049-02-21 17:01:31 -34.56 -99.55 47 -50 \N -80 12 22000 -55 2009-02-16 04:56:57 2023-10-07 13:12:09 0 0 -68 0 \N 61 13 23000 50 2002-11-27 03:01:00 1987-09-12 20:23:02 -68.28 23.91 42 -78 0 97 14 24000 \N 2045-01-03 10:13:13 2086-08-07 23:03:18 0 -26.9 \N \N -70 \N 19 29000 \N 2024-07-15 01:22:12 2054-04-05 00:02:07 \N 24.59 46 0 -29 -47 24 34000 94 2096-01-24 18:22:12 1989-02-19 20:43:45 85.71 0 \N 8 0 -100 68 78000 0 2062-11-28 18:06:53 \N -13.4 58.2 67 \N 89 \N 71 81000 0 2104-04-20 20:42:40 2075-10-12 21:04:23 \N 60.78 -16 -10 8 -17 77 87000 0 \N 2003-03-11 19:11:41 0 -73.81 -89 11 \N 0 78 88000 0 2105-05-24 10:18:51 1973-08-18 23:43:14 \N 82.3 -56 94 5 0 86 96000 -18 2078-11-15 07:35:55 2046-08-18 19:00:30 -28.27 35.58 0 -59 -90 45 89 99000 \N 2065-06-06 21:53:15 2093-06-05 06:29:18 65.81 0 0 0 \N 22 \. -- -- Data for Name: t3; Type: TABLE DATA; Schema: public; Owner: zuming -- COPY public.t3 (vkey, pkey, c15, c16, c17, c18, c19) FROM stdin; 4 14000 1982-02-26 16:53:15 0 62 2106-09-10 05:52:42 -29.87 7 17000 2028-05-24 10:45:17 \N 0 \N 0 38 48000 2078-02-07 17:37:16 3 -78 1989-02-27 23:23:21 59.12 39 49000 2038-09-10 23:10:56 32 \N 1983-04-15 17:59:48 \N 40 50000 2070-07-08 09:44:33 80 0 2073-05-28 16:31:27 0 42 52000 2058-12-18 04:59:10 \N 25 2007-03-03 13:32:55 \N 46 56000 2031-03-20 18:32:25 \N 0 2072-07-09 02:19:24 9.84 49 59000 2018-05-22 06:33:15 -10 44 2018-05-21 11:31:35 79.29 54 64000 2020-05-28 06:17:15 22 0 \N 56.46 61 71000 1983-12-04 01:45:11 -3 96 1996-03-23 08:46:46 72.64 62 72000 2042-03-26 06:33:23 0 0 2051-09-26 05:13:19 -5.84 79 89000 1981-03-28 22:42:10 0 -48 1995-12-24 23:20:55 \N 87 97000 2103-12-25 22:55:37 -90 0 2072-05-08 01:39:50 86.5 90 100000 2072-02-22 19:32:06 31 \N 2100-04-04 23:44:49 0 \. -- -- Data for Name: t5; Type: TABLE DATA; Schema: public; Owner: zuming -- COPY public.t5 (vkey, pkey, c20, c21, c22, c23, c24, c25) FROM stdin; 25 35000 14.56 18 0 \N 1992-10-18 00:48:30 -24 26 36000 0 \N 0 0 2034-11-11 17:32:56 -61 29 39000 -5.47 52 -92.49 3 2042-03-24 10:37:48 5 36 46000 -85.74 -53 -10.11 -22 1997-05-19 21:43:48 0 43 53000 -87.93 \N -12.49 41 2012-10-25 14:59:07 45 45 55000 -95.1 -4 0 0 2011-12-22 06:53:17 -76 57 67000 95.98 2 \N 90 2081-09-26 15:39:20 9 65 75000 -58.32 -94 0 \N 2028-01-13 00:50:12 10 94 104000 -28.88 0 0 -7 2041-07-10 16:25:41 -64 \. -- -- Data for Name: t6; Type: TABLE DATA; Schema: public; Owner: zuming -- COPY public.t6 (vkey, pkey, c26, c27, c28, c29, c30, c31, c32, c33, c34) FROM stdin; 3 13000 \N 0 \N 0 1995-01-22 18:28:53 5.53 -40.69 @VH 2013-06-02 04:35:10 6 16000 \N 0 0 33.18 2106-07-04 08:04:50 5.73 54.95 V@t2 2065-07-08 03:21:15 8 18000 \N -82.34 0 \N 2021-10-26 10:06:51 6.71 0 \N 1989-04-03 08:00:41 9 19000 -2 0 0 0 2014-12-12 17:00:30 -9.63 -48.16 2016-05-08 03:46:39 10 20000 -46 \N -30 -94.3 2026-11-23 23:51:09 83.21 0 T 2010-03-02 20:40:54 17 27000 \N 32.64 19 0 2031-02-11 21:25:48 \N -48.5 f+|/Z 2101-01-14 18:52:03 31 41000 \N \N 7 0 2059-10-27 22:05:06 -29.16 -87.85 9 2019-04-18 15:43:37 47 57000 \N \N 0 -4.24 2016-02-16 10:57:41 0 0 D!~; 1994-09-27 14:34:08 51 61000 96 63.53 0 90.64 2054-02-28 23:38:34 0 22.86 , 2040-08-25 15:10:16 56 66000 -100 10.4 87 44.7 1990-03-25 07:19:35 -49.14 \N -6f) 1970-08-10 07:17:07 64 74000 0 \N 0 0 \N \N \N Z( 2065-12-14 02:23:00 74 84000 0 0 39 31.71 \N -96.61 0 \N 75 85000 10 \N 35 -38.66 2081-12-24 18:08:39 0 \N \N 1998-03-15 09:57:04 80 90000 0 96.9 73 -68.4 1982-07-26 05:02:29 0 98.26 /y 2011-02-20 15:24:54 82 92000 0 0 -96 -63.82 1998-09-26 06:21:35 0 0 Ar:Ip 2095-12-22 00:37:54 85 95000 0 0 55 -59.6 \N -75.9 40.69 2045-12-12 08:24:11 88 98000 0 -34.35 54 -25.68 2079-02-19 23:04:47 0 29.61 LLcI4 \N 92 102000 77 70.63 -38 64.83 2020-04-13 10:28:37 -97.84 -45.78 2100-11-17 20:00:20 95 105000 -39 0 -50 0 2021-11-11 01:50:56 0 96.73 cbv 1996-01-26 14:03:50 96 106000 100 0 0 29.69 2030-03-08 11:05:09 \N 61.6 7`9) 2105-10-24 10:32:26 \. -- -- Name: t0 t0_pkey; Type: CONSTRAINT; Schema: public; Owner: zuming -- ALTER TABLE ONLY public.t0 ADD CONSTRAINT t0_pkey PRIMARY KEY (c1); -- -- Name: t1 t1_pkey; Type: CONSTRAINT; Schema: public; Owner: zuming -- ALTER TABLE ONLY public.t1 ADD CONSTRAINT t1_pkey PRIMARY KEY (pkey); -- -- Name: t5 t5_pkey; Type: CONSTRAINT; Schema: public; Owner: zuming -- ALTER TABLE ONLY public.t5 ADD CONSTRAINT t5_pkey PRIMARY KEY (c20); -- -- Name: i0; Type: INDEX; Schema: public; Owner: zuming -- CREATE INDEX i0 ON public.t6 USING btree (vkey DESC, c28 DESC, c33); -- -- PostgreSQL database dump complete --
unexpected.sql (text/plain, 4.6K) download delete from t1 where (((case when ((t1.vkey in ( select 1 from ((t2 as ref_2 cross join t6 as ref_3) cross join (t2 as ref_4 right outer join t6 as ref_5 on (ref_4.vkey = ref_5.vkey))) where (case when ((ref_5.c26 in ( select ref_5.vkey as c_0 from t6 as ref_6 where ((case when (((exists ( select pg_catalog.stddev_pop(ref_3.c29) over w0 as c_0, ref_21.c32 as c_1 from t6 as ref_21 window w0 as (partition by ref_4.c7 order by t1.vkey asc, t1.pkey asc, t1.c4 desc, t1.c5 asc, ref_2.vkey desc, ref_2.pkey desc, ref_2.c6 asc, ref_2.c7 asc, ref_2.c8 desc, ref_2.c9 desc, ref_2.c10 asc, ref_2.c11 asc, ref_2.c12 asc, ref_2.c13 desc, ref_2.c14 asc, ref_3.vkey asc, ref_3.pkey desc, ref_3.c26 asc, ref_3.c27 desc, ref_3.c28 asc, ref_3.c29 asc, ref_3.c30 asc, ref_3.c31 asc, ref_3.c32 asc, ref_3.c33 asc, ref_3.c34 asc, ref_4.vkey asc, ref_4.pkey desc, ref_4.c6 asc, ref_4.c7 desc, ref_4.c8 desc, ref_4.c9 desc, ref_4.c10 asc, ref_4.c11 asc, ref_4.c12 asc, ref_4.c13 asc, ref_4.c14 desc, ref_5.vkey asc, ref_5.pkey desc, ref_5.c26 asc, ref_5.c27 desc, ref_5.c28 asc, ref_5.c29 desc, ref_5.c30 desc, ref_5.c31 asc, ref_5.c32 desc, ref_5.c33 desc, ref_5.c34 desc, ref_6.vkey asc, ref_6.pkey desc, ref_6.c26 asc, ref_6.c27 asc, ref_6.c28 asc, ref_6.c29 asc, ref_6.c30 asc, ref_6.c31 asc, ref_6.c32 asc, ref_6.c33 desc, ref_6.c34 asc, ref_21.vkey asc, ref_21.pkey asc, ref_21.c26 desc, ref_21.c27 asc, ref_21.c28 desc, ref_21.c29 asc, ref_21.c30 asc, ref_21.c31 desc, ref_21.c32 desc, ref_21.c33 desc, ref_21.c34 asc))) and (not (exists ( select pg_catalog.stddev_pop(ref_3.c29) over w0 as c_0, ref_21.c32 as c_1 from t6 as ref_21 window w0 as (partition by ref_4.c7 order by t1.vkey asc, t1.pkey asc, t1.c4 desc, t1.c5 asc, ref_2.vkey desc, ref_2.pkey desc, ref_2.c6 asc, ref_2.c7 asc, ref_2.c8 desc, ref_2.c9 desc, ref_2.c10 asc, ref_2.c11 asc, ref_2.c12 asc, ref_2.c13 desc, ref_2.c14 asc, ref_3.vkey asc, ref_3.pkey desc, ref_3.c26 asc, ref_3.c27 desc, ref_3.c28 asc, ref_3.c29 asc, ref_3.c30 asc, ref_3.c31 asc, ref_3.c32 asc, ref_3.c33 asc, ref_3.c34 asc, ref_4.vkey asc, ref_4.pkey desc, ref_4.c6 asc, ref_4.c7 desc, ref_4.c8 desc, ref_4.c9 desc, ref_4.c10 asc, ref_4.c11 asc, ref_4.c12 asc, ref_4.c13 asc, ref_4.c14 desc, ref_5.vkey asc, ref_5.pkey desc, ref_5.c26 asc, ref_5.c27 desc, ref_5.c28 asc, ref_5.c29 desc, ref_5.c30 desc, ref_5.c31 asc, ref_5.c32 desc, ref_5.c33 desc, ref_5.c34 desc, ref_6.vkey asc, ref_6.pkey desc, ref_6.c26 asc, ref_6.c27 asc, ref_6.c28 asc, ref_6.c29 asc, ref_6.c30 asc, ref_6.c31 asc, ref_6.c32 asc, ref_6.c33 desc, ref_6.c34 asc, ref_21.vkey asc, ref_21.pkey asc, ref_21.c26 desc, ref_21.c27 asc, ref_21.c28 desc, ref_21.c29 asc, ref_21.c30 asc, ref_21.c31 desc, ref_21.c32 desc, ref_21.c33 desc, ref_21.c34 asc))))) and ((exists ( select pg_catalog.stddev_pop(ref_3.c29) over w0 as c_0, ref_21.c32 as c_1 from t6 as ref_21 window w0 as (partition by ref_4.c7 order by t1.vkey asc, t1.pkey asc, t1.c4 desc, t1.c5 asc, ref_2.vkey desc, ref_2.pkey desc, ref_2.c6 asc, ref_2.c7 asc, ref_2.c8 desc, ref_2.c9 desc, ref_2.c10 asc, ref_2.c11 asc, ref_2.c12 asc, ref_2.c13 desc, ref_2.c14 asc, ref_3.vkey asc, ref_3.pkey desc, ref_3.c26 asc, ref_3.c27 desc, ref_3.c28 asc, ref_3.c29 asc, ref_3.c30 asc, ref_3.c31 asc, ref_3.c32 asc, ref_3.c33 asc, ref_3.c34 asc, ref_4.vkey asc, ref_4.pkey desc, ref_4.c6 asc, ref_4.c7 desc, ref_4.c8 desc, ref_4.c9 desc, ref_4.c10 asc, ref_4.c11 asc, ref_4.c12 asc, ref_4.c13 asc, ref_4.c14 desc, ref_5.vkey asc, ref_5.pkey desc, ref_5.c26 asc, ref_5.c27 desc, ref_5.c28 asc, ref_5.c29 desc, ref_5.c30 desc, ref_5.c31 asc, ref_5.c32 desc, ref_5.c33 desc, ref_5.c34 desc, ref_6.vkey asc, ref_6.pkey desc, ref_6.c26 asc, ref_6.c27 asc, ref_6.c28 asc, ref_6.c29 asc, ref_6.c30 asc, ref_6.c31 asc, ref_6.c32 asc, ref_6.c33 desc, ref_6.c34 asc, ref_21.vkey asc, ref_21.pkey asc, ref_21.c26 desc, ref_21.c27 asc, ref_21.c28 desc, ref_21.c29 asc, ref_21.c30 asc, ref_21.c31 desc, ref_21.c32 desc, ref_21.c33 desc, ref_21.c34 asc))) is not null) ) then (ref_4.c10) else (ref_3.c27) end ) = ref_6.c32) order by c_0 asc)) is not null) then true else (null::bool) end ))) is not null) then true else (null::bool) end )));

view thread (19+ messages)  latest in thread

Message-ID: <db03c582-086d-e7cd-d4a1-3bc722f81765@inf.ethz.ch>
Permalink:  ../db03c582-086d-e7cd-d4a1-3bc722f81765@inf.ethz.ch/
Also on:    postgresql.org/message-id/db03c582-086d-e7cd-d4a1-3bc722f81765@inf.ethz.ch

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: zuming.jiang@inf.ethz.ch, pgsql-bugs@lists.postgresql.org
  Subject: Re: Server closed the connection unexpectedly
  In-Reply-To: <db03c582-086d-e7cd-d4a1-3bc722f81765@inf.ethz.ch>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox