From: Peter Geoghegan <pg@bowt.ie>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix auto_explain index scan NULL pointer dereference.
Date: Thu, 19 Nov 2026 22:53:59 +0000
Message-ID: <E1xUB0w-00000000RZu-3MaM@gemulon.postgresql.org> (raw)
Fix auto_explain index scan NULL pointer dereference.
Commit f026fbf059f, which made IndexScanInstrumentation into a pointer
stored in various executor scan nodes, allocated the underlying
instrumentation state at the point where the executor first initialized
these nodes, though only when the plan was actually going to be run.
This scheme assumed that EXPLAIN would only need to show the relevant
counters for a plan that had actually run.
That was correct for EXPLAIN, but failed to account for
contrib/auto_explain's auto_explain.log_analyze option. This option
sets es->analyze when logging the plan of an EXPLAIN (BUFFERS) without
ANALYZE. The plan wouldn't run there, leading to a NULL pointer
dereference crash.
To fix, check that the instrumentation was allocated before using it.
Author: Xiaoxuan Li <xioxuan@amazon.com>
Discussion: https://postgr.es/m/CANuORAZumpvu2PJwGhVWihKfmUTNcWEbknBZG5-O3aq0uuKbhw@mail.gmail.com
Backpatch-through: 19
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/a20d50a00edc40ff11b08b1e3e3be6e4f9da51f6
Modified Files
--------------
contrib/auto_explain/t/001_auto_explain.pl | 11 +++++++++++
src/backend/commands/explain.c | 13 +++++++++----
2 files changed, 20 insertions(+), 4 deletions(-)
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: pg@bowt.ie
Subject: Re: pgsql: Fix auto_explain index scan NULL pointer dereference.
In-Reply-To: <E1xUB0w-00000000RZu-3MaM@gemulon.postgresql.org>
References: <E1xUB0w-00000000RZu-3MaM@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