| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | nakamurajames123(at)gmail(dot)com |
| Subject: | BUG #19918: SIGSEGV in auto_explain + EXPLAIN (BUFFERS) |
| Date: | 2026-11-19 01:21:24 |
| Message-ID: | 19918-3ea4d551a1a65ca9@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19918
Logged by: Fin
Email address: nakamurajames123(at)gmail(dot)com
PostgreSQL version: 19rc2
Operating system: wsl linux
Description:
Reproduction Steps
Server configuration (postgresql.conf):
shared_preload_libraries = 'auto_explain'
auto_explain.log_min_duration = 0
auto_explain.log_analyze = on
Execute as a regular user:
CREATE TABLE t (id int PRIMARY KEY, v text);
INSERT INTO t SELECT g, 'x' FROM generate_series(1, 1000) g;
ANALYZE t;
EXPLAIN (BUFFERS) SELECT * FROM t WHERE id = 42;
Expected Behavior
Since ANALYZE is not specified in the EXPLAIN command, the query should not
be executed, and only the estimated execution plan should be displayed
successfully.
auto_explain should not treat a plan that was never executed as though it
had been analyzed. If a plan is logged, it should not include actual
execution statistics.
Actual Behavior
The backend crashes with SIGSEGV when the final EXPLAIN (BUFFERS) statement
is executed. The postmaster terminates all other active sessions and
initiates crash recovery.
The issue is consistently reproducible whenever the execution plan contains
an Index Scan.
Both master (20devel, 0cf2d43d326) and PostgreSQL 19.0 (REL_19_STABLE,
19aa5713be2) are affected.
Logs
1. psql output:
CREATE TABLE
INSERT 0 1000
ANALYZE
psql:r.sql:5: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
psql:r.sql:5: error: connection to server was lost
2. Server log (build without sanitizers, cassert enabled, PostgreSQL 20devel
on x86_64-linux, compiled by clang-22.1.8, 64-bit):
2026-11-19 10:19:10.867 KST [3178278] LOG: client backend (PID 3178297) was
terminated by signal 11: Segmentation fault
2026-11-19 10:19:10.867 KST [3178278] DETAIL: Failed process was running:
EXPLAIN (BUFFERS) SELECT * FROM t WHERE id = 42;
2026-11-19 10:19:10.867 KST [3178278] LOG: terminating any other active
server processes
2026-11-19 10:19:10.868 KST [3178278] LOG: all server processes terminated;
reinitializing
2026-11-19 10:19:10.898 KST [3178303] LOG: database system was interrupted;
last known up at 2026-11-19 10:19:10 KST
2026-11-19 10:19:10.904 KST [3178303] LOG: database system was not properly
shut down; automatic recovery in progress
2026-11-19 10:19:10.904 KST [3178303] LOG: redo starts at 0/0175C938
2026-11-19 10:19:10.907 KST [3178303] LOG: invalid record length at
0/017B7400: expected at least 24, got 0
2026-11-19 10:19:10.907 KST [3178303] LOG: redo done at 0/017B7348 system
usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
2026-11-19 10:19:10.907 KST [3178304] LOG: checkpoint starting:
end-of-recovery fast wait
2026-11-19 10:19:10.908 KST [3178304] LOG: checkpoint complete:
end-of-recovery fast wait: wrote 59 buffers (0.4%), wrote 3 SLRU buffers; 0
WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s,
total=0.001 s; sync files=53, longest=0.001 s, average=0.000 s; distance=362
kB, estimate=362 kB
2026-11-19 10:19:10.909 KST [3178278] LOG: database system is ready to
accept connections
3. UBSan stack trace (crash location; source path prefixes have been
shortened):
src/backend/commands/explain.c:3992:45: runtime error: member access within
null pointer of type 'IndexScanInstrumentation' (aka 'struct
IndexScanInstrumentation')
#0 show_indexscan_info src/backend/commands/explain.c:3992:45
#1 ExplainNode src/backend/commands/explain.c:1983:4
#2 ExplainPrintPlan src/backend/commands/explain.c:811:2
#3 explain_ExecutorEnd contrib/auto_explain/auto_explain.c:457:4
#4 ExplainOnePlan src/backend/commands/explain.c:669:2
#5 standard_ExplainOneQuery src/backend/commands/explain.c:380:2
#6 ExplainOneQuery src/backend/commands/explain.c:317:3
#7 ExplainQuery src/backend/commands/explain.c:230:4
#8 standard_ProcessUtility src/backend/tcop/utility.c:868:4
#9 ProcessUtility src/backend/tcop/utility.c:525:3
#10 PortalRunUtility src/backend/tcop/pquery.c:1256:2
#11 FillPortalStore src/backend/tcop/pquery.c:1129:4
#12 PortalRun src/backend/tcop/pquery.c:863:6
#13 exec_simple_query src/backend/tcop/postgres.c:1302:10
#14 PostgresMain src/backend/tcop/postgres.c
#15 BackendMain src/backend/tcop/backend_startup.c:137:2
#16 postmaster_child_launch
src/backend/postmaster/launch_backend.c:268:3
#17 BackendStartup src/backend/postmaster/postmaster.c:3651:8
#18 ServerLoop src/backend/postmaster/postmaster.c:1727:6
#19 PostmasterMain src/backend/postmaster/postmaster.c:1414:11
#20 main src/backend/main/main.c:232:4
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
src/backend/commands/explain.c:3992:45
| From | Date | Subject | |
|---|---|---|---|
| Next Message | PG Bug reporting form | 2026-11-19 01:28:34 | BUG #19919: Internal Invalidation Error During Savepoint DDL After Dropping a Domain Constraint |
| Previous Message | PG Bug reporting form | 2026-11-19 00:37:24 | BUG #19917: nbtree skip scan leaks one copy of a pass-by-reference skip array element per rescan |