[BUGFIX] Fix crash due to sizeof bug in RegisterExtensionExplainOption

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: [BUGFIX] Fix crash due to sizeof bug in RegisterExtensionExplainOption
Date: 2026-03-01 17:10:10
Message-ID: 2a4bd2f5-2a2f-409f-8ac7-110dd3fad4fc@app.fastmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

The allocations in src/backend/commands/explain_state.c
used sizeof(char *) instead of sizeof(ExplainExtensionOption),
which could cause a crash if an extension would register
more than 8 extension EXPLAIN options:

Attached small example extension, test_explain_state.txt,
to demonstrate the bug:

LOAD 'test_explain_state';
LOAD
EXPLAIN (test_explain_opt9) SELECT 1;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
connection to server was lost

/Joel

Attachment Content-Type Size
test_explain_state.txt text/plain 1.5 KB
0001-Fix-sizeof-bug-in-RegisterExtensionExplainOption.patch application/octet-stream 1.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ants Aasma 2026-03-01 17:19:38 Re: Hash aggregate collisions cause excessive spilling
Previous Message Sami Imseih 2026-03-01 15:43:54 Re: pg_stat_statements: Add gc_count and query_file_size to pgss_info