MarkGUCPrefixReserved() doesn't check all options

From: Karina Litskevich <litskevichkarina(at)gmail(dot)com>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: MarkGUCPrefixReserved() doesn't check all options
Date: 2023-07-06 09:17:44
Message-ID: CACiT8ibqyC=_g1n6FXyFJvFW0BEjAH3_5aGqUSFeEp8GpnVrhw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

Ekaterina Sokolova and I have found a bug in PG 15. Since 88103567cb
MarkGUCPrefixReserved() is supposed not only reporting GUCs that haven't
been
defined by the extension, but also removing them. However, it removes them
in
a wrong way, so that a GUC that goes after the removed GUC is never checked.

To reproduce the bug add the following to the postgresql.conf

shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.nonexisting_option_1 = on
pg_stat_statements.nonexisting_option_2 = on
pg_stat_statements.nonexisting_option_3 = on
pg_stat_statements.nonexisting_option_4 = on

and start the server. In the logfile you'll see only first and third options
reported invalid and removed.

In master MarkGUCPrefixReserved() iterates a hash table, not an array as in
PG 15. I'm not sure whether it is safe to remove an entry from this hash
table
while iterating it, but at least I can't reproduce the bug on master.

I attached a bugfix for PG 15.

Best regards,
Karina Litskevich
Postgres Professional: http://postgrespro.com/

Attachment Content-Type Size
v1-0001-Fix-MarkGUCPrefixReserved-to-check-all-options.patch text/x-patch 727 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2023-07-06 09:26:55 Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower
Previous Message Amit Kapila 2023-07-06 08:36:32 Re: pg_decode_message vs skip_empty_xacts and xact_wrote_changes