Re: Expand palloc/pg_malloc API
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-10-31T08:47:05Z
Lists: pgsql-hackers
Attachments
- v2-0001-Add-repalloc0-and-repalloc0_array.patch (text/plain) patch v2-0001
On 11.10.22 18:04, Tom Lane wrote: > Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes: >> On 14.09.22 06:53, Tom Lane wrote: >>> Actually ... an even-more-terrifyingly-plausible misuse is that the >>> supplied oldsize is different from the actual previous allocation. >>> We should try to check that. In MEMORY_CONTEXT_CHECKING builds >>> it should be possible to assert that oldsize == requested_size. >>> We don't have that data if !MEMORY_CONTEXT_CHECKING, but we could >>> at least assert that oldsize <= allocated chunk size. > >> I'm not very familiar with MEMORY_CONTEXT_CHECKING. Where would one get >> these values? > > Hmm ... the individual allocators have that info, but mcxt.c doesn't > have access to it. I guess we could invent an additional "method" > to return the requested size of a chunk, which is only available in > MEMORY_CONTEXT_CHECKING builds, or maybe in !MEMORY_CONTEXT_CHECKING > it returns the allocated size instead. I'm not sure whether that amount of additional work would be useful relative to the size of this patch. Is the patch as it stands now making the code less robust than what the code is doing now? In the meantime, here is an updated patch with the argument order swapped and an additional assertion, as previously discussed.
Commits
-
Add repalloc0 and repalloc0_array
- b4b7ce8061d3 16.0 landed
-
Expand palloc/pg_malloc API for more type safety
- 2864f7755611 10.23 landed
- e962235fe1f6 11.18 landed
- 7dd9b469bc56 12.13 landed
- 172882292451 13.9 landed
- b7f37af7c195 14.6 landed
- 7fe55d5e12b6 15.0 landed
- 2016055a92f2 16.0 landed
-
Assorted examples of expanded type-safer palloc/pg_malloc API
- 5015e1e1b58f 16.0 landed