pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix ASAN failure after flex errors in GUC file parsing
Date: Sun, 16 Aug 2026 23:53:55 +0000
Message-ID: <E1wvkfq-00000000qgn-3ke2@gemulon.postgresql.org> (raw)

Fix ASAN failure after flex errors in GUC file parsing

As detected by ASAN, the scanner value used when parsing GUC files can
be indeterminate when the flex error handler sigjumps to the old cleanup
path, before yylex_init() is called.

The flex scanner state is now made volatile in ParseConfigFp(), since
its value is assigned after sigsetjmp() and cna be accessed after
siglongjmp().  yylex_init() cannot use a volatile pointer; a temporary
variable is used before assigning the result of yylex_init() to it.

While on it, yy_create_buffer() is changed to detect the case where it
returns a NULL value.  Based on my read of the flex code, this cannot be
reached currently.  Future upstream changes or changes in the error
logic of the GUC file parsing could make that reachable, and it is four
extra lines of code.

Oversight in d663f150b5ed.

Reported-by: Ilia Kashintsev <ilia.kashintsev@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrey Rachitskiy <pl0h0yp1@gmail.com>
Discussion: https://postgr.es/m/19612-24ccb4fc6da7786f@postgresql.org
Backpatch-through: 18

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/803583ce74d37c27167bd4d1c9e9dd2421735943

Modified Files
--------------
src/backend/utils/misc/guc-file.l | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1wvkfq-00000000qgn-3ke2@gemulon.postgresql.org>
Permalink:  ../E1wvkfq-00000000qgn-3ke2@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wvkfq-00000000qgn-3ke2@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix ASAN failure after flex errors in GUC file parsing
  In-Reply-To: <E1wvkfq-00000000qgn-3ke2@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