https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125256
Bug ID: 125256
Summary: feature request: Allow malloc-like functions to opt
out of leak warnings
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: andres at anarazel dot de
Target Milestone: ---
Hi,
I'm working on using attribute((malloc,malloc(freeing-function))) etc
annotations for postgres. Unfortunately, for some of the allocators, postgres
uses an arena style allocator (which are called memory contexts in postgres),
where individual memory often is intentionally not freed, as it's considerably
cheaper to throw away the entire context, rather than each individual
allocation.
We also at times are using plain allocators, where we do *not* want to ignore
memory leak warnings.
Therefore I'd like a way to tell the analyzer that for a certain allocator
functions we would like to opt out of leak warnings.
I've tried some workarounds, like replacing all the allocators with an inline
function that pass the returned pointer to an external function - which
suffices to silence the leak warning - but that doesn't really scale to the
number of functions that should signal that they return newly allocated memory.
We still would like to have use-after-free warnings etc
Greetings,
Andres