pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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-00000000Oy3-0Wuw@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_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f296a4148f429ae69359ed65c85417a3bd9f6f56

Modified Files
--------------
src/backend/nodes/nodeFuncs.c | 4 ++++
1 file changed, 4 insertions(+)



view thread (6+ messages)  latest in thread

Message-ID: <E1xWZQ2-00000000Oy3-0Wuw@gemulon.postgresql.org>
Permalink:  ../E1xWZQ2-00000000Oy3-0Wuw@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xWZQ2-00000000Oy3-0Wuw@gemulon.postgresql.org

 · 

reply

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-00000000Oy3-0Wuw@gemulon.postgresql.org>
  References: <E1xWZQ2-00000000Oy3-0Wuw@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