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 1nECC3-0000EL-90 for pgsql-bugs@arkaria.postgresql.org; Sun, 30 Jan 2022 15:32:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nECC2-00012H-6R for pgsql-bugs@arkaria.postgresql.org; Sun, 30 Jan 2022 15:32:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nEC8z-00055H-Ls for pgsql-bugs@lists.postgresql.org; Sun, 30 Jan 2022 15:29:33 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nEC8w-0003VU-BK for pgsql-bugs@lists.postgresql.org; Sun, 30 Jan 2022 15:29:32 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 20UFTRnw216148; Sun, 30 Jan 2022 10:29:27 -0500 From: Tom Lane To: Julien Rouhaud cc: wliang@stu.xidian.edu.cn, pgsql-bugs@lists.postgresql.org Subject: Re: Report a potential bug caused by a improper call to pfree() In-reply-to: <20220130133624.gmxsaxfvkbg4rz7y@jrouhaud> References: <662c1e07.2b1.17ea8e13613.Coremail.wliang@stu.xidian.edu.cn> <20220130133624.gmxsaxfvkbg4rz7y@jrouhaud> Comments: In-reply-to Julien Rouhaud message dated "Sun, 30 Jan 2022 21:36:24 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <216146.1643556567.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 30 Jan 2022 10:29:27 -0500 Message-ID: <216147.1643556567@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Julien Rouhaud writes: > On Sun, Jan 30, 2022 at 10:47:18AM +0800, wliang@stu.xidian.edu.cn wrote= : >> 1160 /* Pop the stack */ >> 1161 parent =3D stack->parent; >> 1162 pfree(stack); >> = >> I think it may be a potential bug and can be fixed without any side-eff= ect as: >> = >> = >> ++ if (stack !=3D &tail) >> 1162 pfree(stack); > I don't think it's necessary, it should be guaranteed that something as = been > pushed on the tail, ie. there shouldn't be a WJB_END_* before a correspo= nding > begin. I've not checked the logic, but the lack of any reported crashes here seems to confirm that there's no bug. regards, tom lane