llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

delegate false-positive memory leak with NSAlert

Open llvmbot opened this issue 18 years ago • 5 comments

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

llvmbot avatar Jul 07 '08 21:07 llvmbot

mentioned in issue llvm/llvm-bugzilla-archive#2542

haoNoQ avatar Nov 26 '21 21:11 haoNoQ

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 ***

haoNoQ avatar Dec 24 '18 00:12 haoNoQ

This project shows as similar (false positive?) potential leak: http://github.com/JanX2/NSTask-Test

llvmbot avatar Feb 13 '10 01:02 llvmbot

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.

tkremenek avatar Jul 11 '08 21:07 tkremenek

assigned to @tkremenek

llvmbot avatar Jul 07 '08 21:07 llvmbot