[cfe-dev] Static analyzer: possible memory leak false positive?

Anna Zaks ganna at apple.com
Fri Sep 28 13:58:54 PDT 2012

On Sep 28, 2012, at 10:32 AM, Eitan Adler <lists at eitanadler.com> wrote:

> On 28 September 2012 07:37, Tijl Coosemans <tijl at coosemans.org> wrote:
>> - Have the analyzer treat return from main like it treats a call to exit(),
>>  at least by default (technically main could be called from another
>>  function).
> This is my preference. Having a default on tunable that treaks main()
> like exit().

This might silence too many leak reports. Ex: If main allocates memory in the very beginning, which is not used later on, followed by all the processing, followed by return. We have a bug report tracking this internally, I'll update with the suggestion.


>> - Have an analyzer_free() function which acts like free to the analyzer
>>  but is a no-op to the compiler. The experimental malloc checker supports
>>  this:
> I would very much prefer not this option. It requires special annotation for the
> analyzer to work correctly. csa has been very good about avoiding this
> until now.
>> - Declare mntbuf static which tells the analyzer the memory is allowed to
>>  persist for the lifetime of the process.
> This seems more of a workaround for an analyzer bug than a solution in
> the general case.
> -- 
> Eitan Adler

More information about the cfe-dev mailing list