Closed
Bug 1170388
Opened 9 years ago
Closed 8 years ago
Static analyzer false positives about lambdas using local (non-captured) raw pointers to refcounted objects
Categories
(Developer Infrastructure :: Source Code Analysis, defect)
Developer Infrastructure
Source Code Analysis
Tracking
(firefox41 fixed, firefox43 fixed)
RESOLVED
FIXED
mozilla43
People
(Reporter: botond, Assigned: botond)
References
(Blocks 1 open bug)
Details
(Keywords: regression)
Attachments
(1 file)
The patches in bug 1158424 trip [1] the static analysis added in bug 1153304 even though the lambda they introduce does not *capture* a raw pointer to a refcounted object - it merely takes one as argument. I believe this is perfectly safe - it's just like any other function taking a raw pointer to the refcounted object. The point of bug 1153304 was to guard against *capturing* such a pointer, since that gets stored inside the lambda which may in turn outlive its caller. [1] http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/bballo@mozilla.com-96128147095d/try-linux64-st-an-debug/try-linux64-st-an-debug-bm79-try1-build46.txt.gz
Assignee | ||
Comment 1•9 years ago
|
||
Bug 1170388 - Restrict the static analysis error given about raw pointers to refcounted objects inside a lambda, to the case where the raw pointer is captured. r=ehsan
Attachment #8614972 -
Flags: review?(ehsan)
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → botond
Updated•9 years ago
|
Attachment #8614972 -
Flags: review?(ehsan) → review+
Comment 2•9 years ago
|
||
Comment on attachment 8614972 [details] MozReview Request: Bug 1170388 - Removed an outdated workaround for old clang versions in the static analysis plugin. r=mystor https://reviewboard.mozilla.org/r/10131/#review8949 Ship It!
Assignee | ||
Comment 4•9 years ago
|
||
Backed out in https://hg.mozilla.org/integration/mozilla-inbound/rev/b0b9843b8654 for bustage. Looks like automation's using clang 3.3 for the static analysis, but my patch uses the matcher 'equalsBoundNode' which was only added in clang 3.4.
Comment 5•9 years ago
|
||
(In reply to Botond Ballo [:botond] from comment #4) > Backed out in > https://hg.mozilla.org/integration/mozilla-inbound/rev/b0b9843b8654 for > bustage. > > Looks like automation's using clang 3.3 for the static analysis, but my > patch uses the matcher 'equalsBoundNode' which was only added in clang 3.4. Ugh. You can probably copy its implementation... IIRC I had to do the same for example for IsInSystemHeader.
Assignee | ||
Comment 6•9 years ago
|
||
Comment on attachment 8614972 [details] MozReview Request: Bug 1170388 - Removed an outdated workaround for old clang versions in the static analysis plugin. r=mystor Bug 1170388 - Restrict the static analysis error given about raw pointers to refcounted objects inside a lambda, to the case where the raw pointer is captured. r=ehsan
Attachment #8614972 -
Flags: review+ → review?(ehsan)
Assignee | ||
Comment 7•9 years ago
|
||
Updated patch to polyfill equalsBoundNode on clang < 3.4. It wasn't a straight copy of the 3.4 implementation because some of the infrastructure changed, but it seems to be working. Try push showing that it's working: https://treeherder.mozilla.org/#/jobs?repo=try&revision=bfd42baee21f Posting for re-review. Note that the only change from the last patch is the added hunk that provides equalsBoundNode.
Updated•9 years ago
|
Attachment #8614972 -
Flags: review?(ehsan) → review+
Comment 8•9 years ago
|
||
Comment on attachment 8614972 [details] MozReview Request: Bug 1170388 - Removed an outdated workaround for old clang versions in the static analysis plugin. r=mystor https://reviewboard.mozilla.org/r/10131/#review9189 Ship It! ::: build/clang-plugin/clang-plugin.cpp:611 (Diff revision 2) > + const NodeType& Node; Nit: we try to use the LLVM coding style for this file, so * and & should be attached to the variable names here and elsewhere. ::: build/clang-plugin/clang-plugin.cpp:622 (Diff revision 2) > + Visitor* visitor = new Visitor(Node, ID, haveMatchingResult); Hmm, why are you allocating this on the heap? It seems like it could live on the stack.
Assignee | ||
Comment 9•9 years ago
|
||
(In reply to :Ehsan Akhgari (not reading bugmail, needinfo? me!) from comment #8) > Comment on attachment 8614972 [details] > MozReview Request: Bug 1170388 - Restrict the static analysis error given > about raw pointers to refcounted objects inside a lambda, to the case where > the raw pointer is captured. r=ehsan > > https://reviewboard.mozilla.org/r/10131/#review9189 > > Ship It! > > ::: build/clang-plugin/clang-plugin.cpp:611 > (Diff revision 2) > > + const NodeType& Node; > > Nit: we try to use the LLVM coding style for this file, so * and & should be > attached to the variable names here and elsewhere. Fixed. > ::: build/clang-plugin/clang-plugin.cpp:622 > (Diff revision 2) > > + Visitor* visitor = new Visitor(Node, ID, haveMatchingResult); > > Hmm, why are you allocating this on the heap? It seems like it could live > on the stack. My reason was that visitMatches() takes the visitor by pointer, but that's a bad reason :) Fixed.
https://hg.mozilla.org/mozilla-central/rev/03ff333d49c0
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
Assignee | ||
Comment 12•9 years ago
|
||
The fact that the static analysis is still triggering [1] on my patches in bug 1158424 indicates that the fix for clang 3.3 isn't correct. Reopening. [1] https://treeherder.mozilla.org/#/jobs?repo=try&revision=5ff606ee785a
Assignee | ||
Updated•9 years ago
|
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 13•9 years ago
|
||
I spent some time trying to debug this the issue on the cland 3.3 codepath, without luck. Ehsan and I discussed this briefly and agreed that a better way forward is to upgrade automation to use clang >= 3.4.
Flags: needinfo?(ehsan)
Assignee | ||
Comment 14•9 years ago
|
||
Going to unassign for now as I have no immediately plans to continue working on this. If we end up upgrading automation's clang to >= 3.4, that will solve the issue without further work, otherwise I can continue trying to find a 3.3 workaround after Whistler.
Assignee: botond → nobody
Updated•9 years ago
|
Summary: Static analyzer objects to lambda taking as argument a raw pointer to a refcounted object → Static analyzer false positives about lambdas using local (non-captured) raw pointers to refcounted objects
Assignee | ||
Comment 15•9 years ago
|
||
Bug 1123386 has now landed, which upgrades the clang version used for the static analysis builds in automation to >= 3.4. I believe this upgrade should resolve this issue. Once we verify that this is the case (by someone landing a patch that uses lambdas that use non-captured raw pointers to refcounted objects and that patch passing static analysis), I'll land a patch in this bug to remove my attempt at a pre-3.4 solution (which never worked) that landed in comment 11.
Flags: needinfo?(ehsan)
Assignee | ||
Comment 16•8 years ago
|
||
(In reply to Botond Ballo [:botond] from comment #15) > Bug 1123386 has now landed, which upgrades the clang version used for the > static analysis builds in automation to >= 3.4. I believe this upgrade > should resolve this issue. > > Once we verify that this is the case (by someone landing a patch that uses > lambdas that use non-captured raw pointers to refcounted objects and that > patch passing static analysis), I'll land a patch in this bug to remove my > attempt at a pre-3.4 solution (which never worked) that landed in comment 11. Bug 1200413 has made this point moot by rewriting the static analysis to not use the 'equalsBoundNode' matcher that I was trying to polyfill. I'll post a patch to remove the (broken) polyfill attempt.
Assignee | ||
Comment 17•8 years ago
|
||
Comment on attachment 8614972 [details] MozReview Request: Bug 1170388 - Removed an outdated workaround for old clang versions in the static analysis plugin. r=mystor Bug 1170388 - Removed an outdated workaround for old clang versions in the static analysis plugin. r=mystor
Attachment #8614972 -
Attachment description: MozReview Request: Bug 1170388 - Restrict the static analysis error given about raw pointers to refcounted objects inside a lambda, to the case where the raw pointer is captured. r=ehsan → MozReview Request: Bug 1170388 - Removed an outdated workaround for old clang versions in the static analysis plugin. r=mystor
Attachment #8614972 -
Flags: review?(michael)
Comment 18•8 years ago
|
||
Comment on attachment 8614972 [details] MozReview Request: Bug 1170388 - Removed an outdated workaround for old clang versions in the static analysis plugin. r=mystor https://reviewboard.mozilla.org/r/10131/#review16409 LGTM
Attachment #8614972 -
Flags: review?(michael) → review+
https://hg.mozilla.org/mozilla-central/rev/d7fed4b3bb8a
Status: REOPENED → RESOLVED
Closed: 9 years ago → 8 years ago
status-firefox43:
--- → fixed
Resolution: --- → FIXED
Target Milestone: mozilla41 → mozilla43
Updated•8 years ago
|
Assignee: nobody → botond
Updated•6 years ago
|
Product: Core → Firefox Build System
Updated•1 year ago
|
Product: Firefox Build System → Developer Infrastructure
You need to log in
before you can comment on or make changes to this bug.
Description
•