Re: [PATCH] bms_prev_member() can read beyond the end of the array of allocated words
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Greg Burd <greg@burd.me>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-08-14T23:06:33Z
Lists: pgsql-hackers
On Fri, 15 Aug 2025 at 07:45, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Anyway, that's off-topic for the present thread. I believe it's > middle-of-the-night in Rowley's time zone, so I was waiting for > further comment from him before taking any action. The v5 patch looks good to me. FWIW, after sleeping, I'm now very much against using < rather than <= for the Assert. The reason being that it makes it impossible to build bms_prev_member() loops with a dynamic start point. Right now we document that we expect the loop to be started with -1, but if someone wants to start at some arbitrary point in the set, then they need to be able to pass some_member + 1. If some_member happens to be the highest bit in the last word then your Assert will fail for no good reason. I'm happy to push Greg's v5 patch if you have no counterarguments. David
Commits
-
Add Asserts to validate prevbit values in bms_prev_member
- b4632883d44e 19 (unreleased) landed