Re: PgStat_HashKey padding issue when passed by reference

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PgStat_HashKey padding issue when passed by reference
Date: 2025-09-04 16:50:15
Message-ID: CAA5RZ0sOkyubFPJzZ_Sv4sdBV89C6WTDAc-B8ZE_-bTk8ggViA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > This looks like a compiler bug, we tested multiple ways to workaround:
>
> Padding bytes aren't guaranteed to be zeroed, unless you take care to zero
> them out with memset or such. That's not a compiler bug.

Perhaps calling this a compiler bug is not appropriate.
However, memset is in fact called when the key is created

```
/* clear padding */
memset(&key, 0, sizeof(struct PgStat_HashKey));
```

but the zeroed out padding bytes are not retained when the
key is passed by value. This is why the proposal is to pass the
key by reference.

--
Sami Imseih
Amazon Web Services (AWS)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2025-09-04 16:50:43 Re: Logical Replication of sequences
Previous Message Andres Freund 2025-09-04 16:45:48 Re: PgStat_HashKey padding issue when passed by reference