Suppress: Static Analysis false positive.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Suppress: Static Analysis false positive.

Steven Osborn
I have a bit of code I'm calling from a Apple's StoreKit library that
looks something like:

http://pastebin.com/1YgyXPf9

Where you release the object in the callback function which leads to a
false positive for a memory leak.

I've dug through the documentation, but I can't find anything to help
me suppress this particular warning.

Thanks in advance,

--
Steven Osborn
http://steven.bitsetters.com
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Suppress: Static Analysis false positive.

Ted Kremenek
The analyzer currently doesn't handle delegates in a clean way, so cases like these are helpful to see.  Could you file a bugzilla report with this example?  At the very least we can potentially silence the analyzer in these cases, and have it do something smarter over time.

Thanks,
Ted

On Feb 25, 2010, at 9:13 AM, Steven Osborn wrote:

> I have a bit of code I'm calling from a Apple's StoreKit library that
> looks something like:
>
> http://pastebin.com/1YgyXPf9
>
> Where you release the object in the callback function which leads to a
> false positive for a memory leak.
>
> I've dug through the documentation, but I can't find anything to help
> me suppress this particular warning.
>
> Thanks in advance,
>
> --
> Steven Osborn
> http://steven.bitsetters.com
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Suppress: Static Analysis false positive.

Ted Kremenek
In reply to this post by Steven Osborn
On Feb 25, 2010, at 9:13 AM, Steven Osborn wrote:

> I've dug through the documentation, but I can't find anything to help
> me suppress this particular warning.


In general I'm not so found of a general "silence this warning" annotation for the static analyzer, as really the goal is to make the analyzer smarter.  Annotations (e.g., attribute(noreturn)) that educate the analyzer about program semantics are one thing, and they are good to use from a software engineering perspective because they document the assumptions of the code.  But for cases where the analyzer is just outright confused, I'd prefer we get bug reports so we can just make it smarter.  That way it benefits everyone who uses the analyzer.  Chances are if you are seeing a false positive someone else has seen it too.

The analyzer can be a lot more clever than a compiler warning, so there we should never approach a false positive as "this is something the analyzer could never figure out."  Even if solving the general analysis problem is hard, often identifying a case where the analyzer would have difficulty is trivial, and in such cases we can take a conservative approach of not issuing a warning.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Suppress: Static Analysis false positive.

Ken Ferry
In reply to this post by Steven Osborn
Ideally you should avoid this when programming Cocoa.  Retains and releases should be balanced within every method, with certain structured exceptions like accessors.  When you do it as you have here it isn't just harder for the static analyzer, it's harder for you. For example, if the framework added cancellation via new instance method and corresponding delegate callback, you'd have to update your code to avoid a leak.  

In this case, if possible, make the outstanding request a property of your object.

-Ken
Cocoa Frameworks

On Thu, Feb 25, 2010 at 9:13 AM, Steven Osborn <[hidden email]> wrote:
I have a bit of code I'm calling from a Apple's StoreKit library that
looks something like:

http://pastebin.com/1YgyXPf9

Where you release the object in the callback function which leads to a
false positive for a memory leak.

I've dug through the documentation, but I can't find anything to help
me suppress this particular warning.

Thanks in advance,

--
Steven Osborn
http://steven.bitsetters.com
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev