Avoid a spurious UBSan failure for empty parallel XID lists

A parallel VACUUM can start workers without having an assigned XID,
leaving parallelCurrentXids empty.  Since 7a04cac0c3b annotated this
array with counted_by, Clang's bounds sanitizer can reject taking
&parallelCurrentXids[0] when the count is zero.  No element is accessed:
the leader copies zero bytes and the worker only saves the base pointer.
This seems to be compiler-specific, gcc does not reject the access.

Use the array itself as the base pointer in both paths, avoiding the
subscript without changing the serialized representation.

No backpatch, as this affects only branches with 7a04cac0c3b.

Author: Tomas Vondra <[email protected]>
Discussion: 
https://www.postgresql.org/message-id/flat/DKBEBF32QLUA.3L2DJRPUYNKHZ%40partin.io

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d140a3a666a3b072f45108a847554837431d96e7

Modified Files
--------------
src/backend/access/transam/xact.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

Reply via email to