pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix auto_explain index scan NULL pointer dereference.
2+ messages / 1 participants
[nested] [flat]

* pgsql: Fix auto_explain index scan NULL pointer dereference.
@ 2026-11-19 22:53  Peter Geoghegan <pg@bowt.ie>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Geoghegan @ 2026-11-19 22:53 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Fix auto_explain index scan NULL pointer dereference.
@ 2026-11-19 22:53  Peter Geoghegan <pg@bowt.ie>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Geoghegan @ 2026-11-19 22:53 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/921c555eb2e32d246383d92183c06df4112e96b9

Modified Files
--------------
contrib/auto_explain/t/001_auto_explain.pl | 11 +++++++++++
src/backend/commands/explain.c             |  9 ++++++---
2 files changed, 17 insertions(+), 3 deletions(-)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-11-19 22:53 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 22:53 pgsql: Fix auto_explain index scan NULL pointer dereference. Peter Geoghegan <pg@bowt.ie>
2026-11-19 22:53 pgsql: Fix auto_explain index scan NULL pointer dereference. Peter Geoghegan <pg@bowt.ie>

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