| From: | Japin Li <japinli(at)hotmail(dot)com> |
|---|---|
| To: | "Tristan Partin" <tristan(at)partin(dot)io> |
| Cc: | "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Add counted_by attribute |
| Date: | 2026-07-30 05:08:10 |
| Message-ID: | SY7PR01MB109214FE7167533EF7A8C9748B6C92@SY7PR01MB10921.ausprd01.prod.outlook.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, 29 Jul 2026 at 22:07, "Tristan Partin" <tristan(at)partin(dot)io> wrote:
> The counted_by[0] compiler attribute is fairly new. It was added in GCC
> 15 and Clang 18. It has been used fairly extensively in the Linux
> kernel[0].
>
> To summarize the benefits of the attribute:
>
> - Runtime bounds checking with -DFORTIFY_SOURCE=3 and -fsanitize-bounds
> - Accurate reporting of __builtin_dynamic_object_size()
>
> While we don't use __builtin_dynamic_object_size(), I think the runtime
> bounds checking improvements are easily worth the little bit of effort
> to add the attribute in various locations and review the code. I think
> it will improve things for buildfarm animals using ASan due to expanded
> coverage.
>
> Adding this attribute to the codebase was previously proposed back in
> 2024[1], but the thread never got any traction. I figured that I would
> try again, but bring some patches this time. I figured that I would
> start small, and then after people agree that it has value, I can look
> into adding the attribute in many more places.
>
> [0]: https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-counted_005fby
> [1]: https://people.kernel.org/gustavoars/how-to-use-the-new-counted_by-attribute-in-c-and-linux
> [2]: https://www.postgresql.org/message-id/ME3P282MB3166210CDE36BD485B703BF6B6C82@ME3P282MB3166.AUSP282.PROD.OUTLOOK.COM
>
+1 for this idea.
> --
> Tristan Partin
> PostgreSQL Contributors Team
> AWS (https://aws.amazon.com)
--
Regards,
Japin Li
ChengDu WenWu Information Technology Co., Ltd.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ashutosh Bapat | 2026-07-30 05:11:39 | Re: doc: Add PROPERTY GRAPH to the access privilege tables |
| Previous Message | vignesh C | 2026-07-30 04:44:42 | Re: Race between pg_dump and ALTER SEQUENCE can cause read failure |