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 1kZSmy-0001RH-6c for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Nov 2020 05:53:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kZSmv-0008CC-FN for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Nov 2020 05:53:53 +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 1kZSmv-0008C5-9M for pgsql-bugs@lists.postgresql.org; Mon, 02 Nov 2020 05:53:53 +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 1kZSmt-0007Oc-9I for pgsql-bugs@lists.postgresql.org; Mon, 02 Nov 2020 05:53:52 +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 0A25rmqY595535; Mon, 2 Nov 2020 00:53:48 -0500 From: Tom Lane To: Andrey Borodin cc: tvijlbrief@gmail.com, pgsql-bugs@lists.postgresql.org, Tomas Vondra Subject: Re: BUG #16694: Server hangs in 100% CPU loop when decompressing a specific TOAST Postgis linestring In-reply-to: <727877DF-78F7-4C1E-B1A5-C0A97BF276CE@yandex-team.ru> References: <16694-f107871e499ec114@postgresql.org> <543595.1604267856@sss.pgh.pa.us> <578150.1604274357@sss.pgh.pa.us> <592336.1604294205@sss.pgh.pa.us> <727877DF-78F7-4C1E-B1A5-C0A97BF276CE@yandex-team.ru> Comments: In-reply-to Andrey Borodin message dated "Mon, 02 Nov 2020 10:33:09 +0500" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <595533.1604296428.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 02 Nov 2020 00:53:48 -0500 Message-ID: <595534.1604296428@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andrey Borodin writes: >> 2 =D0=BD=D0=BE=D1=8F=D0=B1. 2020 =D0=B3., =D0=B2 10:16, Tom Lane =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0): >> Yeah, I was wondering about that. Not quite sure it's worth adding >> cycles to defend against though. > I think so too. That's why I was not protecting from corruption at all w= hen proposing c60e520. > Here we can have core dump too if *(srcend+1) produce SegFault: Right. The "sp > srcend" check that I added doesn't help if we were unlucky enough to be right up against the end of memory. I judged it was cheap enough to be worth including, but I'd agree that's a judgment call. Conversely, checking for "off" being too far back would require tracking the distance back to the start of the output buffer, which is a value the loop does not keep ATM. So that would require adding more cycles to track (in addition to the actual comparison), which is why it seemed not quite worth it. regards, tom lane