Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Issue 10005022: Check for public dtors on base::RefCounted types (Closed)

Created:
8 years, 8 months ago by Ryan Sleevi
Modified:
8 years, 8 months ago
Reviewers:
Nico
CC:
chromium-reviews, pam+watch_chromium.org
Visibility:
Public.

Description

Check and warn if public destructors are found on types that derive from base::RefCounted or base::RefCountedThreadSafe. Having public destructors is dangerous, as it allows the ref-counted object to be stack allocated and have references that attempt to outlive the stack, or to allow callers to explicitly delete it while references are still held. Both patterns result in use-after-free, hence their prohibition. In doing so, update the Chromium plugin to be able to scan both headers and implementation files, and enable the public destructor check for both types with an optional flag ( -Xclang -plugin-arg-find-bad-constructs -Xclang skip-refcounted-dtors ) BUG=123295 TEST=none Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=132500

Patch Set 1 #

Total comments: 1

Patch Set 2 : Just RefCounted #

Total comments: 5

Patch Set 3 : Really working - and with tests #

Patch Set 4 : Now with moar flags #

Total comments: 6

Patch Set 5 : Nit & Style fixes #

Patch Set 6 : Copyright update #

Unified diffs Side-by-side diffs Delta from patch set Stats (+502 lines, -155 lines) Patch
M tools/clang/plugins/ChromeClassTester.h View 1 2 3 4 5 3 chunks +18 lines, -11 lines 0 comments Download
M tools/clang/plugins/ChromeClassTester.cpp View 1 2 3 4 5 7 chunks +138 lines, -123 lines 0 comments Download
M tools/clang/plugins/FindBadConstructs.cpp View 1 2 3 4 5 6 chunks +123 lines, -15 lines 0 comments Download
A tools/clang/plugins/tests/base_refcounted.h View 1 2 3 4 1 chunk +121 lines, -0 lines 0 comments Download
A tools/clang/plugins/tests/base_refcounted.cpp View 1 2 1 chunk +72 lines, -0 lines 0 comments Download
A tools/clang/plugins/tests/base_refcounted.txt View 1 2 3 4 1 chunk +23 lines, -0 lines 0 comments Download
M tools/clang/plugins/tests/inline_ctor.h View 1 2 2 chunks +4 lines, -4 lines 0 comments Download
M tools/clang/scripts/plugin_flags.sh View 1 2 3 4 5 2 chunks +3 lines, -2 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
Ryan Sleevi
Nico: This is what I've been/am/will be using to pick up the bad patterns. I'll ...
8 years, 8 months ago (2012-04-05 22:10:40 UTC) #1
Nico
This looks good. To check performance, please do three clobber builds of a big target ...
8 years, 8 months ago (2012-04-05 23:08:13 UTC) #2
Ryan Sleevi
On 2012/04/05 23:08:13, Nico wrote: > This looks good. > > To check performance, please ...
8 years, 8 months ago (2012-04-11 20:30:25 UTC) #3
Ryan Sleevi
Nico: Want to take a look at the updated (Just the RefCounted) changes? This also ...
8 years, 8 months ago (2012-04-11 22:18:57 UTC) #4
Nico
Code looks great, but please add a test as well. There's a ghetto 'runtests' script ...
8 years, 8 months ago (2012-04-11 22:27:26 UTC) #5
Ryan Sleevi
Nico, PTAL once more - now with tests and proper handling of typedefs and qualified-ids. ...
8 years, 8 months ago (2012-04-12 04:21:53 UTC) #6
Ryan Sleevi
Nico: Per IRC, I added a flag so that this is disabled by default. Please ...
8 years, 8 months ago (2012-04-13 22:16:04 UTC) #7
Nico
Few nits http://codereview.chromium.org/10005022/diff/18001/tools/clang/plugins/FindBadConstructs.cpp File tools/clang/plugins/FindBadConstructs.cpp (right): http://codereview.chromium.org/10005022/diff/18001/tools/clang/plugins/FindBadConstructs.cpp#newcode40 tools/clang/plugins/FindBadConstructs.cpp:40: const Type* UnwrapType(const Type* type) { Does ...
8 years, 8 months ago (2012-04-13 22:40:55 UTC) #8
Ryan Sleevi
http://codereview.chromium.org/10005022/diff/18001/tools/clang/plugins/FindBadConstructs.cpp File tools/clang/plugins/FindBadConstructs.cpp (right): http://codereview.chromium.org/10005022/diff/18001/tools/clang/plugins/FindBadConstructs.cpp#newcode40 tools/clang/plugins/FindBadConstructs.cpp:40: const Type* UnwrapType(const Type* type) { On 2012/04/13 22:40:55, ...
8 years, 8 months ago (2012-04-14 00:16:29 UTC) #9
Ryan Sleevi
alrighty, I'm feelin lucky. Any more nits?
8 years, 8 months ago (2012-04-14 00:17:22 UTC) #10
Nico
lgtm
8 years, 8 months ago (2012-04-14 00:48:55 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/rsleevi@chromium.org/10005022/21002
8 years, 8 months ago (2012-04-14 01:08:45 UTC) #12
Nico
No need for cq, that tests nothing for this patch
8 years, 8 months ago (2012-04-14 01:14:25 UTC) #13
commit-bot: I haz the power
8 years, 8 months ago (2012-04-14 03:44:24 UTC) #14
Try job failure for 10005022-21002 (retry) on mac_rel for step "browser_tests".
It's a second try, previously, step "browser_tests" failed.
http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=mac_rel&nu...

Powered by Google App Engine
This is Rietveld 408576698