From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Prevent stack overflow in exprLocation()
Date: Thu, 26 Nov 2026 13:21:46 +0000
Message-ID: <E1xWZQ2-00000000Oy9-0nEv@gemulon.postgresql.org> (raw)
Prevent stack overflow in exprLocation()
exprLocation() recurses down to the leftmost token of an expression
without checking the stack depth. A statement like:
(SELECT 1 ORDER BY 1) ORDER BY 1+1+...+1
with a million terms therefore crashed the backend while computing the
error position for "multiple ORDER BY clauses not allowed".
Author: Zsolt Parragi <zsolt.parragi@percona.com>
Discussion: https://www.postgresql.org/message-id/CAN4CZFOJzyQ73OxeyRs2QCh7FfBDWqEAsNDiKm1G0hB9Cn6fhw@mail.gmail...
Backpatch-through: 15
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/9c82763b966d11e238645ea1081b94d1d037a5a0
Modified Files
--------------
src/backend/nodes/nodeFuncs.c | 4 ++++
1 file changed, 4 insertions(+)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: heikki.linnakangas@iki.fi
Subject: Re: pgsql: Prevent stack overflow in exprLocation()
In-Reply-To: <E1xWZQ2-00000000Oy9-0nEv@gemulon.postgresql.org>
References: <E1xWZQ2-00000000Oy9-0nEv@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox