delegate false-positive memory leak with NSAlert
| Bugzilla Link | 2526 |
| Resolution | DUPLICATE |
| Resolved on | Dec 23, 2018 16:12 |
| Version | unspecified |
| OS | MacOS X |
| Attachments | test case |
| Reporter | LLVM Bugzilla Contributor |
| CC | @tkremenek,@haoNoQ |
Extended Description
I noticed a false-positive memory leak when using the NSAlert class. The reason is that the NSAlert object can be released later when the 'didEndSelector' is called (the call to beginSheet... is asynchronous).
Please see tha attachment.
Using checker-57.
Thanks
mentioned in issue llvm/llvm-bugzilla-archive#2542
Delegate-related false positives were suppressed in r69992 as part of llvm/llvm-bugzilla-archive#2542
*** This bug has been marked as a duplicate of bug llvm/llvm-bugzilla-archive#2542 ***
This project shows as similar (false positive?) potential leak: http://github.com/JanX2/NSTask-Test
This bug is related to PR 2542, so I'll reproduce a comment I just made there.
Delegates are an idiom that the analyzer eventually needs to handle to cut down on an important source of false positives (and also potentially find other bugs). Some of this will require interprocedural analysis (IPA), which I have been gradually laying the groundwork for in the analyzer core. While it will be a while before doing IPA across source files, we can first start by doing IPA within a single file. Since @implementations don't span multiple files, I think even this limited IPA will get some traction in the short-term.
The question is what to do when we cannot analyze the methods used for the delegate idiom. Even with full-blown, cross-file IPA, if the source of a method or class is not available we will have to make assumptions. I think for methods involving delegates that the checker should opt for false negatives instead of false positives. We can tailor the checker to take this strategy for well-known delegate APIs, which hopefully will handle 90% of the common cases where the analyzer get's it wrong. Once more IPA features come into play, we can improve the precision and do more checking.
assigned to @tkremenek