Re: [PATCH] bms_prev_member() can read beyond the end of the array of allocated words

Greg Burd <greg@burd.me>

From: Greg Burd <greg@burd.me>
To: Tom Lane <tgl@sss.pgh.pa.us>, David Rowley <dgrowleyml@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-08-14T19:32:09Z
Lists: pgsql-hackers
Tom, David,

I really appreciate the time spent and the thoughtful replies on this
thread today. Honestly, I thought this would be a nice and easy single
line fix ahead of a proposal for the addition of tests for Bitmapset[1]
(which identified the issue)

I think, with v5, we're fixing this small issue in a reasonable and
understandable manner.  Any chance we can agree on it and get back to
the bigger fish in the frying pan? :)

Spoiler alert, I have larger plans[2] for Bitmapset which is why I
started down this road to begin with as I wanted to capture the existing
API/contract for it before I proposed changes to it.

best,

-greg

[1] https://github.com/gburd/postgres/pull/11/commits/0bd90e6ce7954d4324748f18717508cce64afc22
[2] https://codeberg.org/gregburd/sparsemap - a compressed bitmap index



Commits

  1. Add Asserts to validate prevbit values in bms_prev_member