Hi,
On 2026-09-08 18:52:58 +0700, Ilya Cherdakov wrote:
> 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.
Perhaps a stupid question, but: Who cares? This is a test module, intended to
write tests for bms_*. I feel like we have much better things to do than to
prevent somebody triggering asserts while write tests in an intentionally bad
way?
Greetings,
Andres Freund