Assert in test_bms_membership();

From: Ilya Cherdakov <i(dot)cherdakov(dot)pg(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: drowley(at)postgresql(dot)org
Subject: Assert in test_bms_membership();
Date: 2026-09-08 11:52:58
Message-ID: af8ddd01-853d-4752-82f3-0808498c992c@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Postgresql 19 added a new module, src/test/modules/test_bitmapset.
It contains the function test_bms_membership(), which is a wrapper
around bms_membership. Passing some string that are not valid Bitmapset
representation to this function will result to assert. For example

SELECT test_bms_membership('b 1 2)');
or
SELECT test_bms_membership('true');

[backtrace.txt]

|The assertion appears to occur becaus| in
#define TEXT_TO_BITMAPSET(str) (test_bitmapset.c:91) casts to Bitmapset*
without type checking, using stringToNode, which obviously can return
types other than T_Bitmapset (read.c:247). This pointer, with the wrong
type, is then passed to bms_membership, where it fails the assert
with type checking (bitmapset.c:905).

The fix simply adds a check whether the type is valid or not,
as done in the bms_is_valid_set()(bitmapset.c:87) function.

---

Best regards,
Ilya Cherdakov
Postgres Professional: https://postgrespro.com

Attachment Content-Type Size
backtrace.txt text/plain 3.1 KB
0001-Validate-Bitmapset-input-in-test_bitmapset.patch text/plain 1.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-09-08 11:55:11 Re: Use C11 alignas instead of palloc/malloc for alignment
Previous Message Palak Chaturvedi 2026-09-08 11:24:37 Re: Changing shared_buffers without restart