Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tFtw3-00HGWW-FN for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Nov 2024 11:40:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tFtw2-006PDT-4c for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Nov 2024 11:40:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tFtw1-006PDK-1w for pgsql-hackers@lists.postgresql.org; Tue, 26 Nov 2024 11:40:49 +0000 Received: from fhigh-b5-smtp.messagingengine.com ([202.12.124.156]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tFtvx-0047ml-BW for pgsql-hackers@postgresql.org; Tue, 26 Nov 2024 11:40:48 +0000 Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.stl.internal (Postfix) with ESMTP id B3BFF25401C1; Tue, 26 Nov 2024 06:40:42 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Tue, 26 Nov 2024 06:40:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1732621242; x=1732707642; bh=t /neguqtmnor4XcTpfzLu+w0bFQaN0QejnXvesQVoSM=; b=gZ6P/yzM49tjRDPxW +X+j1BMwPDU0F3uF3S0M5EVI1bj7o/mVGY2qnLMw3w/7KRIMnlKvRFYDhx0BEsT/ zvh71sV295ztOF1RxDwGogUj+TXpeIK6y7bntRPgPmnnoEJBo9o+fc+gw3cqy4bN 09+/cokc7S2Gk6hMRyY05V+BXdzGGBo3qdJAnqgcSBoyPKT6vb3QIp4gFuxL94cM swKMjBRMktd+b5rscPJt2A63mjHhvIvLVNX+tMFgmsIXMHglISRU4Z7kc2Q+hHlJ sV5hxc16grwqVjzhKUyxCgcOXVrOf+0kZxTUn7TLpLFtUUtXxkm0owjAV1bjBbJX ej3wA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrgeejgddvjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvfevuf fkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgr uceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvg hrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeekfffgudffhfduffffueev necuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhh rdhnohdqihhprdhorhhgpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuth dprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhsseguihhmrgdrnhhikhhithhinhdr nhgrmhgvpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqh hlrdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 26 Nov 2024 06:40:42 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1732621239; bh=PPFg9VZpzoqGrGbEbplQ7GmWDuhuH/rs1PUTEmKBi+M=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=GD7KqPMPjEjRI5J6pjrjLinrJNsgoh7my3bbDMd86xJCIguXsmKwakB/nQTR+L6v+ wtTW7HtTHUTxbHqy0yfzoCAtcFkNcLmq33HcWaansLQ1wBdTuhXSQbf4zPP+GYEDJw RX+qlRW4AfHVxYx/b5vHB4lQ7B+tBhA3MEOSRe2JnpwMMHfqZZYkhBwvjHQD9cWIK2 MpvgFc903drTkbyvEDPVOzGC7Hvz8Mrno4ZNHRCOeSQnh67hIu1eQVQQ7nT2NT5N00 wzgf8MOI2R3fGuseHIzqYo3XiuaL9AXteO2bShX70d4w1aIBYgfQ1BtXj78iwkLTmp 2dQUoKCiI0m4A== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id E2C8F95; Tue, 26 Nov 2024 12:40:39 +0100 (CET) Date: Tue, 26 Nov 2024 12:40:39 +0100 From: Alvaro Herrera To: Dmitry Nikitin Cc: pgsql-hackers@postgresql.org Subject: Re: [PATCH] Missing Assert in the code Message-ID: <202411261140.2mhmulgt2xav@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <172136986.20241126122437@dima.nikitin.name> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello On 2024-Nov-26, Dmitry Nikitin wrote: > Monday, November 25, 2024, 10:51:31 PM, you wrote: > > AH> Hmm, I think if we believe this to be really possible, we should have an > AH> 'if/elog' test (or maybe a full ereport with ERRCODE_DATA_CORRUPTED > AH> errcode) rather than an assertion. I think the assertion adds nothing > AH> of value here, but maybe an 'if' test would. > I don't mind of 'if' however it's not clear for me what to follow on > other (error) branch of that 'if'. An elog(ERROR) doesn't continue execution of the function (it's a longjmp to transaction abort and error recovery), so you don't have to worry about that. My point is that an Assert() is only executed in a debug build; production builds don't have assertions. > AH> Did you examine the other callers of PageGetMaxOffsetNumber()? It's a > AH> large bunch. > Mostly it used in loops. So some code will be gracefully skipped and > that's it. Yeah, I noticed that in a few that I looked at, but it's over a hundred of them. > However the case discussed is different because -1 index of an array > will be accessed. Which is much worse than a bare assertion at least. Sure. By the way, how did you find out about this problem? Is this hypothetical or was there an actual crash? AFAICS (some of?) the callers get to this code immediately after executing GinInitPage, so it's not clear to me that there's an actual bug here. ... Ah, maybe ginFindLeafPage could be at risk, through ->isMoveRight. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "Porque Kim no hacía nada, pero, eso sí, con extraordinario éxito" ("Kim", Kipling)