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 1pnjPg-0006TM-0U for pgsql-bugs@arkaria.postgresql.org; Sat, 15 Apr 2023 17:10:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pnjPe-0007m6-Ux for pgsql-bugs@arkaria.postgresql.org; Sat, 15 Apr 2023 17:10:10 +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 1pn00s-0007aq-2j for pgsql-bugs@lists.postgresql.org; Thu, 13 Apr 2023 16:41:34 +0000 Received: from azure-sdnproxy.icoremail.net ([52.229.205.26]) by magus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1pn00n-002fzP-7F for pgsql-bugs@lists.postgresql.org; Thu, 13 Apr 2023 16:41:33 +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=irKzdHz36bMt1MZh1Rop60zxCcMtY+7HUn+LQM5n3iI=; b=W1h2LvIbXGCtySY7AGysNWZz+GMDVALeWygb7nISer6bN4uQue1xPH9apNFJS8 TDr6LQCf3UKIYDAEC7KRmTX5xCj7L6D3X5Cks5lXTaHV3Z22qj+GA+vk5lqDRUhC q+Zm6HKyhPn5HDAf+I/7oeKkpAwkeH9XD0ASAgui+MStg= Received: from LAPTOPJPQFQS7K (unknown [183.172.66.176]) by web2 (Coremail) with SMTP id yQQGZQBXtJK0MDhkqCL_Eg--.58972S2; Fri, 14 Apr 2023 00:41:24 +0800 (CST) From: To: Cc: , Subject: =?us-ascii?Q?6._PostgreSQL_Server_Subprocess_Went_down_at_Function_'has?= =?us-ascii?Q?=5Fdangerous=5Fjoin=5Fusing'?= Date: Fri, 14 Apr 2023 00:41:27 +0800 Message-ID: <00b601d96e26$cad72410$60856c30$@mails.tsinghua.edu.cn> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00B7_01D96E69.D8FB2760" X-Mailer: Microsoft Outlook 16.0 Content-Language: zh-cn Thread-Index: AdluJsH5w+t8Nv8ORliTotlgRDhjsg== X-CM-TRANSID: yQQGZQBXtJK0MDhkqCL_Eg--.58972S2 X-Coremail-Antispam: 1UD129KBjvJXoW7ArykKF1DZw1UXw45Ww1ftFb_yoW5JF4DpF y3Kas0yFW7Gw18WrWUXrWjva1kCaykJ343Grn7Gr15Zay5XrWq9asFyFWjgayY9r4kCr10 ka42yF929a909w7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUQ2b7Iv0xC_Cr1lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I 8E87Iv6xkF7I0E14v26rxl6s0DM2vYz4IE04k24VAvwVAKI4IrM2AIxVAIcxkEcVAq07x2 0xvEncxIr21l5I8CrVAYj202j2C_Wr0_Ar1l5I8CrVAqjxCE14ACF2xKxwAqx4xG64kEw2 xG04xIwI0_Gr0_Xr1l5I8CrVCF0I0E4I0vr24lYx0E2Ix0cI8IcVAFwI0_JF0_Jw1lYx0E x4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwAKzV CY07xG64k0F24lc2xSY4AK67AK6r1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_ Jr0_Gr1l4IxYO2xFxVAFwI0_Jrv_JF1lx2IqxVAqx4xG67AKxVWUGVWUWwC20s026x8Gjc xK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1Y6r17MIIYrxkI7VAKI48JMIIF0xvE2Ix0 cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8V AvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E 14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUargAUUUUU 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_00B7_01D96E69.D8FB2760 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Description: PostgreSQL Server Subprocess Went down at Function 'has_dangerous_join_using' 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 TABLE i (t int, b text, gist_point_tbl text) PARTITION BY RANGE (t); CREATE VIEW gist_point_tbl WITH (security_barrier) AS SELECT * FROM i l NATURAL JOIN i r; UPDATE pg_attribute SET attisdropped = true WHERE attrelid = 'i'::regclass AND attname = 'gist_point_tbl'; select pg_get_viewdef('gist_point_tbl'); ``` Backtrace: ``` #0 0x1accaf3 (has_dangerous_join_using+0x883) #1 0x1acc79c (has_dangerous_join_using+0x52c) #2 0x1ac3b4f (set_deparse_for_query+0x49f) #3 0x1aadfe3 (get_query_def+0x5d3) #4 0x1aeb96b (make_viewdef+0x3db) #5 0x1aa8a54 (pg_get_viewdef_worker+0x654) #6 0x1aa8f13 (pg_get_viewdef_name+0x83) #7 0xe84bc5 (ExecInterpExpr+0x23e5) #8 0xe81cee (ExecInterpExprStillValid+0xbe) #9 0xfc4805 (ExecEvalExprSwitchContext+0x85) #10 0xfc45ff (ExecProject+0x18f) #11 0xfc3f93 (ExecResult+0x463) #12 0xedbf36 (ExecProcNodeFirst+0x116) #13 0xec0e2c (ExecProcNode+0x7c) #14 0xeb3a9f (ExecutePlan+0x1df) #15 0xeb3780 (standard_ExecutorRun+0x550) #16 0xeb3224 (ExecutorRun+0x64) #17 0x16f6361 (PortalRunSelect+0x241) #18 0x16f53bd (PortalRun+0x7ed) #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 0x7feec1f2d083 (__libc_start_main+0xf3) #27 0x49fc0e (_start+0x2e) ``` ------=_NextPart_000_00B7_01D96E69.D8FB2760 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Description: = PostgreSQL Server Subprocess Went down at Function = ‘has_dangerous_join_using’

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 TABLE = i (t int, b text, gist_point_tbl text) PARTITION BY RANGE = (t);

CREATE VIEW = gist_point_tbl WITH (security_barrier) AS

  &= nbsp;    SELECT * FROM i l NATURAL JOIN i = r;

UPDATE = pg_attribute SET attisdropped =3D true

  &= nbsp; WHERE attrelid =3D 'i'::regclass AND attname =3D = 'gist_point_tbl';

select = pg_get_viewdef('gist_point_tbl');

```

 

Backtrace:

```

#0 0x1accaf3 = (has_dangerous_join_using+0x883)

#1 0x1acc79c = (has_dangerous_join_using+0x52c)

#2 0x1ac3b4f = (set_deparse_for_query+0x49f)

#3 0x1aadfe3 = (get_query_def+0x5d3)

#4 0x1aeb96b = (make_viewdef+0x3db)

#5 0x1aa8a54 = (pg_get_viewdef_worker+0x654)

#6 0x1aa8f13 = (pg_get_viewdef_name+0x83)

#7 0xe84bc5 = (ExecInterpExpr+0x23e5)

#8 0xe81cee = (ExecInterpExprStillValid+0xbe)

#9 0xfc4805 = (ExecEvalExprSwitchContext+0x85)

#10 0xfc45ff = (ExecProject+0x18f)

#11 0xfc3f93 = (ExecResult+0x463)

#12 0xedbf36 = (ExecProcNodeFirst+0x116)

#13 0xec0e2c = (ExecProcNode+0x7c)

#14 0xeb3a9f = (ExecutePlan+0x1df)

#15 0xeb3780 = (standard_ExecutorRun+0x550)

#16 0xeb3224 = (ExecutorRun+0x64)

#17 = 0x16f6361 (PortalRunSelect+0x241)

#18 = 0x16f53bd (PortalRun+0x7ed)

#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 = 0x7feec1f2d083 (__libc_start_main+0xf3)

#27 0x49fc0e = (_start+0x2e)

```

 

------=_NextPart_000_00B7_01D96E69.D8FB2760--