Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eu9q5-0004v3-5z for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Mar 2018 04:41:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eu9q3-0005pI-P5 for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Mar 2018 04:41:03 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eu9q3-0005p9-14 for pgsql-bugs@lists.postgresql.org; Fri, 09 Mar 2018 04:41:03 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eu9pz-0000r4-Ig for pgsql-bugs@lists.postgresql.org; Fri, 09 Mar 2018 04:41:01 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id CB77513ED; Thu, 8 Mar 2018 23:40:57 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Thu, 08 Mar 2018 23:40:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=KgdscWcPaoXY9wl8tsXHfiO32ZZm9F7JKi+mM4ye2iw=; b=tn+l7LS9 3HMeTUHuK96wQXF5gPgXY8j8/lsuX5ldkSEzeCiivYLJpNc1Hn9Lug1ZM0MHhmmY Spc3d4fspHY2WjL716xwMGkJbkMNLQrQnwj2WYRxFf1z3V8sY3VF7GFNl/+8qBC1 srkymxe9H/ec5Pevw3p8aWjUxWP99Ae3BN6ZfLVr5MeI7gR+4vNxUT99UDjmyWpN 0Vh4Pq0J7RsoBGMaL2ORsILO3M0vopiIJWRqGj4IazeniV1bDoDNRc7EhzFGKqqN C5yn7NSeB1R4OiMwWfUErDXFVzxxMCIiJ3XXxGKB13Fn7psxDLQPWDZ1+n8tcxAd KS6J9NgVgGgj/w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=KgdscWcPaoXY9wl8tsXHfiO32ZZm9 F7JKi+mM4ye2iw=; b=Wnwy0I5KQI6I6Dhn8PN4p77XjDzHWR5vrH+jYkfPcEqUB /QL5NSmEGd9hmlgvTGPRrTE8hd+tGwkCLHlm5SC4ceqVqKiCToFuK3GV+dFk+BJi 5QH7t5CW85NwroS/yorMUXDkyaCrFgg9j3X9pKo4mg0+I3YQpCZBz3F6hP6F1rZU 2o5Vu4AUcFDYab+xhPx6MrW9AzQ8tPMeFToSdK+9Q7HIY6bhNMmb4P9JvyHYRyPA gGm+gRtpEwS3ih8Ddnbud4B2GlHJDC4Q1aMMFkF+gspOsHpWwx4qZtzPzUliQ+Ib twTu8YnR/wURvgpthxvJYkgwYp6nG7OTcjyVnRroQ== X-ME-Sender: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 5DFED24550; Thu, 8 Mar 2018 23:40:55 -0500 (EST) Date: Fri, 9 Mar 2018 13:40:52 +0900 From: Michael Paquier To: bianpan2016@163.com, pgsql-bugs@lists.postgresql.org Cc: Robert Haas Subject: Re: BUG #15105: OpenTransientFile() should be paired with CloseTransientFile() rather than close() Message-ID: <20180309044052.GC1416@paquier.xyz> References: <152056616579.4966.583293218357089052@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="UfEAyuTBtIjiZzX6" Content-Disposition: inline In-Reply-To: <152056616579.4966.583293218357089052@wrigleys.postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --UfEAyuTBtIjiZzX6 Content-Type: multipart/mixed; boundary="V88s5gaDVPzZ0KCq" Content-Disposition: inline --V88s5gaDVPzZ0KCq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Mar 09, 2018 at 03:29:25AM +0000, PG Bug reporting form wrote: > Details: The handler opened with OpenTransientFile() should be closed with > CloseTransientFile(). However, in function dsm_impl_mmap(), on a certain > path, the return value of OpenTransientFile() (at line 885) is passed to > close() (at line 926). It is better to use CloseTransientFile() here, as > done at line 909. Good catch! This is visibly a copy-paste error coming from dsm_impl_posix(). As a patch it gives the attached. I am adding also Robert in CC for awareness. -- Michael --V88s5gaDVPzZ0KCq Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="dsm-impl-close.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/storage/ipc/dsm_impl.c b/src/backend/storage/ipc/d= sm_impl.c index 67e76b98fe..10a7a56875 100644 --- a/src/backend/storage/ipc/dsm_impl.c +++ b/src/backend/storage/ipc/dsm_impl.c @@ -923,7 +923,7 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size reques= t_size, =20 /* Back out what's already been done. */ save_errno =3D errno; - close(fd); + CloseTransientFile(fd); if (op =3D=3D DSM_OP_CREATE) unlink(name); errno =3D save_errno; --V88s5gaDVPzZ0KCq-- --UfEAyuTBtIjiZzX6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlqiEFQACgkQnvQgOdby QH1eGg/9ESUYmkw+SUxxxIwHnvhUOBIfk2MtQDXwuYOFwDd4jqDGEzBIy0IyKL4/ nCDhckK0iVT0uRWN6BnkelIPV1+cWicwIEBGihOe6ARyxw59X2yMcpgbMQ1eP7X/ hZisiLnajJBwo8qC9uRB+NM9INx+M3dBOCcdpt5Go5qV6cQar0EKzhPywUm77ekb c42WCkmD4PKOQUeU3WKu4b3DuyoGcIJRo3DU2CI6/dumbZioGx8eHoAZR54fGIS9 xT7EFGvchUHLWecSsqycgz38arii4VyaRiB2XeVDU4Lq4R/c9ZzUryCu+BSEyauB cZ2rrLLWkWBeqATKlUEaN8oqZ9Olnh3MKmm+fpCG3hXVK4G8mVNx/4LLjQhihIgX cQZdLLv3w3GPX09rn3gyNe4pYgm+JeCYcEeVOG5TE7wE3AhZjpnQSzwNf7NX4Dw+ cOYo1MkIh9EyyztXKLxVGjl8rCDcdDeG6B5fdQ21Qcq3kQAE7GR+RK1JdngIIDnK J+cvBbgKtrKrp6zG4hCPCIrlKkVd2OnZ6nzYT2ZihCUUxA+WtTVcmZiuJTxzaFL/ lT5aCuPCalRYPqELYvF2IbwPmF5d8zV/vcTNeQUkAXWOz0iva/sG+PrQnDd5XN1T KZZKHwxmsFgEzjBye8Dr1aC0hZ+jxHchqtrlsvRsh39dPy9Y7vQ= =RGvo -----END PGP SIGNATURE----- --UfEAyuTBtIjiZzX6--