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 1ndzHR-0007a4-Ez for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Apr 2022 19:00:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ndzHQ-0001Qm-A9 for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Apr 2022 19:00:52 +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 1ndzHP-0001QY-94 for pgsql-bugs@lists.postgresql.org; Mon, 11 Apr 2022 19:00:52 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ndzHK-0004h7-1F for pgsql-bugs@lists.postgresql.org; Mon, 11 Apr 2022 19:00:50 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 4EB665C003B; Mon, 11 Apr 2022 15:00:44 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 11 Apr 2022 15:00:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1649703644; x=1649790044; bh=YNsdkDV4Kg +jXF8fIcJFgwgTwEZfqJ3rq/cRGIUqk/U=; b=J0PNrH1dcCVxEtSHKYqsFjeJ63 nWZ14dzW7VEtiYudCTccgsUC3sjL60xF8LllU/gbK4kWaM4ZXqxpt56ZXbYiu7+8 pMVSeHYOwviAoXG+uLmlJTr+vxEUMmPoPZfK8Ml4oMx+DukrgYmWXzHLdk7H8PQe IZYu3QhLawcamNH7Mt0EaspfrLaX4SFA5Y+opxiTNO97x1GAZSpz6xy1qkeOPXFv HLdGp5UugpFsYhYNZ1TyH6kf4YI3ONdDIqXMgNHR5dJ7KNHJjqPDppSnqnuD715X PsjsQpZ14fePJpsRA7sI/K7vCmBniL8J13qeDILsRMimGFQzA4UBGKO6GRQA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1649703644; x= 1649790044; bh=YNsdkDV4Kg+jXF8fIcJFgwgTwEZfqJ3rq/cRGIUqk/U=; b=M ToQqyasfsrSUPF0MhBjwQiiX7RTKIX46tu0OqDpx9vfyJ5XrMj4SBXQbnH/ZCIcP esulbURHJ/3uqm7O4ginWDRfG6CuvBG/67eCS9mKWV45tcj8aN8zBaDSTSsIKZ6+ B/XwmMc0DfN29+PhYnuJJ24b3yHt1DTxpZaryC/wTipgCeyCUZHUevyt5mTV+Gpv YDu9m1dndhpTmo2xNe3Y5BFAnYJ0Hq3J1ACq9K+g0LkCOLnXbe74S7Qwu6aqLKPg /ENzLra3fre6M0qoovEXpCNhU4X+vOqwOgizevPAuMGXYarxxF5vY3NWRPeDIY13 za6or4zY8eApKjA+ishGg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudekiedgudeffecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjsehttd ertddttddvnecuhfhrohhmpeetnhgurhgvshcuhfhrvghunhguuceorghnughrvghssegr nhgrrhgriigvlhdruggvqeenucggtffrrghtthgvrhhnpedukefhkeelueegveetheelff ffjeegleeuudelfeefuedtleffueejfffhueffudenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Apr 2022 15:00:43 -0400 (EDT) Date: Mon, 11 Apr 2022 12:00:42 -0700 From: Andres Freund To: Tom Lane Cc: anisimow.d@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17462: Invalid memory access in heapam_tuple_lock Message-ID: <20220411190042.o5ebdhc5qsejleff@alap3.anarazel.de> References: <17462-9c98a0f00df9bd36@postgresql.org> <286748.1649692519@sss.pgh.pa.us> <288544.1649693991@sss.pgh.pa.us> <20220411173417.ocwjn5xrkqqjiysl@alap3.anarazel.de> <352840.1649699498@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <352840.1649699498@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2022-04-11 13:51:38 -0400, Tom Lane wrote: > Andres Freund writes: > > One way to address it in a way not requiring an API break would be to pass > > SnapshotAny to heap_fetch and then do an explicit visibility check "ourselves" > > in heapam_lock_tuple(). > > I'm not really interested in fixing this without an API break (going > forward anyway), because as it stands heap_fetch is just an invitation > to make this same mistake again. My suggestion was about the back branch situation... But it seems viable going forward as well, if we we reset tuple->t_data in the !valid case. As you say: > It should never return a tuple pointer if we don't keep the pin on the > associated buffer. Agreed. If tuple->t_data were reset in the !valid case, not just the !ItemIdIsNormal() case, bug would have been noticed immediately (isolation tests do fail, I checked). Another approach is to extend the SatisfiesDirty approach and store the tid of the next tuple version in addition the xmin/xmax we already store. And have heap_fetch() always set t_data to NULL if the snapshot check fails. Greetings, Andres Freund