Re: Add malloc attribute to memory allocation functions

From: "Tristan Partin" <tristan(at)partin(dot)io>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Michael Paquier" <michael(at)paquier(dot)xyz>
Cc: "Peter Eisentraut" <peter(at)eisentraut(dot)org>, "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add malloc attribute to memory allocation functions
Date: 2026-07-07 23:57:23
Message-ID: DJSQVBYR1O3S.W4ZMXLOEPRBH@partin.io
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue Jul 7, 2026 at 6:54 PM CDT, Tom Lane wrote:
> Michael Paquier <michael(at)paquier(dot)xyz> writes:
>> Additional question. Does this help with requirements like the one
>> listed in fe-exec.c for PQfreemem() under WIN32?
>
> Yeah, I was wondering about that point too. It would be really nice
> to have automated checks for that. Maybe the right thing to do here
> (to start anyway) is to put in targeted annotations that address
> specific pain points like that one.
>
> One issue that'd have to be dealt with is that that would involve
> putting annotations into the public header file libpq-fe.h. We'd need
> to be sure we do not break things for applications using compilers
> other than what we built libpq with. That seems reasonably easy to do
> with some macro trickery, but it's a point to keep in mind.

Ok, I think the path forward is two-fold:

1. Add the annotations to specific pain points as Tom suggested
(PGfreemem(), frontend memory allocators)
2. Add the annotations to the backend allocators knowing that the patch
may not be committed

--
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2026-07-07 23:58:39 Re: SPLIT/MERGE use of is_internal=true
Previous Message Tom Lane 2026-07-07 23:54:06 Re: Add malloc attribute to memory allocation functions