tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Leak Sanitizer - how to suppress leaks



On 13.09.2019 03:24, Simon Burge wrote:
> Kamil Rytarowski wrote:
> 
>> I will revert it, but I am looking for a more generic approach.
>>
>> How about adding ifdef __NO_LEAKS like:
>>
>> #ifdef __NO_LEAKS
>> free(3)?
>> #endif
>>
>> And in lsan/asan/valgrind/etc checks use -D__NO_LEAKS.
> 
> Sorry if I'm missing something that has been already explained,
> but why (practically) do we care about memory leaks for a utility
> that is about to finish?
> 

I used it in the first place when the resource was no longer needed and
it happened to be before return by an accident.

> If we're doing some ugly #ifdef dance only when running the
> sanitiser(s), then we haven't actually done anything to "fix"
> the leak in the installed binaries so it seems that there was
> no practical problem that we were trying to solve in the first
> place.
> 

It's an optimization to free the resource by exit(2). It is legal in a
POSIX environment, so no need to change this default behavior.

Whenever we affect long-running applications or incomplete procedure
shutdown, we could add free(3) calls unconditionally.

> Cheers,
> Simon.
> 


Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index