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.96) (envelope-from ) id 1vIVnV-003nRc-0r for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Nov 2025 17:35:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vIVnS-001nb3-2G for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Nov 2025 17:35:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vIVnS-001nav-1N for pgsql-bugs@lists.postgresql.org; Mon, 10 Nov 2025 17:35:18 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vIVnQ-006Pd8-2c for pgsql-bugs@lists.postgresql.org; Mon, 10 Nov 2025 17:35:17 +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 5AAHZ7cB1889907; Mon, 10 Nov 2025 12:35:07 -0500 From: Tom Lane To: Andrey Zhidenkov cc: Heikki Linnakangas , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19108: Stack overflow duting query parse In-reply-to: References: <19108-13b9dd7a2d30a9cc@postgresql.org> <1879801.1762790568@sss.pgh.pa.us> Comments: In-reply-to Andrey Zhidenkov message dated "Mon, 10 Nov 2025 19:12:40 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1889905.1762796107.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 10 Nov 2025 12:35:07 -0500 Message-ID: <1889906.1762796107@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrey Zhidenkov writes: >> Could you at least provide a not-mangled-to-the-point-of-incorrectness > version of the query? > Sure, here it is: > ... Thanks. I made this into a full-size test case by just duplicating one of the lines 1000 times. (The parser is not going to notice whether the values are equal, though possibly we'd detect that later.) We do produce a deeply nested boolean OR tree from this WHERE condition, but I don't see any indication that that should be a problem. It works just fine for me at the default max_stack_depth, and even down to max_stack_depth =3D '300kB', and below that I get a clean failure: ERROR: stack depth limit exceeded HINT: Increase the configuration parameter "max_stack_depth" (currently 2= 00kB), after ensuring the platform's stack depth limit is adequate. So I seriously doubt that Postgres is doing anything wrong. It looks to me like your machine is/was under serious memory pressure and that was causing the kernel to do strange things like refuse to expand the stack as much as was promised by getrlimit(). You might want to compare the swap and OOM-killer configuration on the problematic machine to ones that are okay. Another, probably more far-fetched theory is some kind of hardware issue on that machine --- bad RAM or the like. regards, tom lane