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

Issue 1665553002: metrics: Connect leak detector to allocator (Closed)

Created:
4 years, 10 months ago by Simon Que
Modified:
4 years, 9 months ago
CC:
chromium-reviews, extensions-reviews_chromium.org, Dai Mikurube (NOT FULLTIME), vmpstr+watch_chromium.org, wfh+watch_chromium.org, asvitkine+watch_chromium.org, chromium-apps-reviews_chromium.org, bccheng, dhsharp, rapati, tipp, bjanakiraman
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

metrics: Connect leak detector to base::allocator This patch introduces the leak detector's integration layer, which gathers alloc/free info and passes it to the leak detection logic in LeakDetectorImpl. It registers callbacks with the allocator, which are called during alloc and free. These callbacks intercept and sample the alloc and free info. It also provides a notification interface for external objects to receive leak reports. See leak_detector.cc for more info. BUG=chromium:382705 TEST=build successfully, run components_unittests Committed: https://crrev.com/be8dae533a69fc2c2a71a03193bc59de7570999a Cr-Commit-Position: refs/heads/master@{#381293}

Patch Set 1 #

Patch Set 2 : Fixed unit testing issues #

Patch Set 3 : Use base::Lock; Create LeakDetector class #

Total comments: 1

Patch Set 4 : Change LeakDetector class to be a simple singleton #

Total comments: 10

Patch Set 5 : Rebased on top of other CL #

Patch Set 6 : Add unit test for allocator hook registration #

Total comments: 5

Patch Set 7 : Add missing include #

Total comments: 20

Patch Set 8 : Replace CHECK w/ return; Optimize sampling; Move some code out of lock; Binary mapping on CrOS only #

Patch Set 9 : Simplify alloc hook registration; Enclose more stuff in CrOS #ifdef #

Total comments: 7

Patch Set 10 : Remove FRIEND macro; Add comment about LeakDetector class thread safety #

Patch Set 11 : Remove use of add_pointer; Simplify GetCallStack #

Total comments: 26

Patch Set 12 : Set binary mapping info, fwd declare LeakDetectorImpl, add TODO for posting analysis task #

Patch Set 13 : Make leaky singleton; Use TLS to count hook entry; Fix sampling calculation #

Patch Set 14 : Use leaky lazy instance instead of singleton; Use saturated_cast to compute sampling factor #

Total comments: 4

Patch Set 15 : Updated comments based on wfh's feedback #

Patch Set 16 : Free memory allocated within hooks #

Total comments: 15

Patch Set 17 : Fix casting, pointer accessor; formatting #

Patch Set 18 : Restore deleted include #

Total comments: 10

Patch Set 19 : primiano's feedback; Register observer sooner #

Unified diffs Side-by-side diffs Delta from patch set Stats (+379 lines, -52 lines) Patch
M base/allocator/allocator_extension.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +20 lines, -0 lines 0 comments Download
M base/allocator/allocator_extension.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +22 lines, -0 lines 0 comments Download
M chrome/browser/metrics/leak_detector_controller.h View 1 2 3 4 5 6 7 8 9 10 11 12 16 17 1 chunk +0 lines, -3 lines 0 comments Download
M chrome/browser/metrics/leak_detector_controller.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +6 lines, -8 lines 0 comments Download
M components/metrics/leak_detector/leak_detector.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4 chunks +80 lines, -16 lines 0 comments Download
M components/metrics/leak_detector/leak_detector.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +242 lines, -11 lines 0 comments Download
M components/metrics/leak_detector/leak_detector_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 3 chunks +9 lines, -14 lines 0 comments Download

Messages

Total messages: 77 (14 generated)
Simon Que
Here's an outline of what this patch contains: - base/allocator/allocator_extension.*: Added functions for registering alloc/free ...
4 years, 10 months ago (2016-02-03 02:54:21 UTC) #3
Will Harris
On 2016/02/03 02:54:21, Simon Que wrote: > Here's an outline of what this patch contains: ...
4 years, 10 months ago (2016-02-03 05:02:33 UTC) #4
Simon Que
On 2016/02/03 05:02:33, Will Harris wrote: > On 2016/02/03 02:54:21, Simon Que wrote: > > ...
4 years, 10 months ago (2016-02-03 17:51:12 UTC) #5
Will Harris
On 2016/02/03 17:51:12, Simon Que wrote: > On 2016/02/03 05:02:33, Will Harris wrote: > > ...
4 years, 10 months ago (2016-02-03 18:43:57 UTC) #6
Simon Que
4 years, 10 months ago (2016-02-03 18:47:12 UTC) #7
Will Harris
more top level questions before getting to the nittygritty https://codereview.chromium.org/1665553002/diff/40001/components/metrics/leak_detector/leak_detector.cc File components/metrics/leak_detector/leak_detector.cc (right): https://codereview.chromium.org/1665553002/diff/40001/components/metrics/leak_detector/leak_detector.cc#newcode74 components/metrics/leak_detector/leak_detector.cc:74: ...
4 years, 10 months ago (2016-02-04 03:41:52 UTC) #9
Simon Que
On 2016/02/04 03:41:52, Will Harris wrote: > more top level questions before getting to the ...
4 years, 10 months ago (2016-02-04 03:47:20 UTC) #10
Will Harris
On 2016/02/04 03:47:20, Simon Que wrote: > On 2016/02/04 03:41:52, Will Harris wrote: > > ...
4 years, 10 months ago (2016-02-04 04:03:23 UTC) #11
Simon Que
On 2016/02/04 04:03:23, Will Harris wrote: > On 2016/02/04 03:47:20, Simon Que wrote: > > ...
4 years, 10 months ago (2016-02-04 05:00:27 UTC) #12
Simon Que
Is this class a good example of a singleton class? LoginState: https://code.google.com/p/chromium/codesearch#chromium/src/chromeos/login/login_state.h&q=login_state&sq=package:chromium&l=43
4 years, 10 months ago (2016-02-04 19:06:30 UTC) #13
Will Harris
On 2016/02/04 19:06:30, Simon Que wrote: > Is this class a good example of a ...
4 years, 10 months ago (2016-02-04 19:22:12 UTC) #14
Simon Que
On 2016/02/04 19:22:12, Will Harris wrote: > On 2016/02/04 19:06:30, Simon Que wrote: > > ...
4 years, 10 months ago (2016-02-04 19:32:33 UTC) #15
Will Harris
looks like PerfProvider is a simple (non singleton or lazyinstance) class that's just a member ...
4 years, 10 months ago (2016-02-05 04:38:17 UTC) #16
Simon Que
On 2016/02/05 04:38:17, Will Harris wrote: > looks like PerfProvider is a simple (non singleton ...
4 years, 10 months ago (2016-02-05 05:49:02 UTC) #17
Simon Que
PTAL.
4 years, 10 months ago (2016-02-08 18:38:47 UTC) #18
Will Harris
I've added asvitkine to the review as an owner of base/metrics he will be able ...
4 years, 10 months ago (2016-02-08 19:42:26 UTC) #20
Simon Que
On 2016/02/08 19:42:26, Will Harris (ooo until 25 Feb) wrote: > I've added asvitkine to ...
4 years, 10 months ago (2016-02-09 22:31:07 UTC) #21
Alexei Svitkine (slow)
That sgtm. On 9 Feb 2016 5:31 p.m., <sque@chromium.org> wrote: > > On 2016/02/08 19:42:26, ...
4 years, 10 months ago (2016-02-09 22:34:23 UTC) #22
Simon Que
I've marked all the globals that I think can be moved to LeakDetector class or ...
4 years, 10 months ago (2016-02-09 22:45:54 UTC) #23
Simon Que
Will, I've rebased this on top of the other CL. While we're waiting for that ...
4 years, 10 months ago (2016-02-26 02:09:25 UTC) #26
Simon Que
PTAL, the other patch has landed.
4 years, 10 months ago (2016-02-27 00:45:36 UTC) #28
Simon Que
4 years, 9 months ago (2016-02-29 21:04:40 UTC) #30
Primiano Tucci (use gerrit)
Gave a first pass. My main comment here is: - the API surface in base ...
4 years, 9 months ago (2016-03-01 18:54:37 UTC) #31
Simon Que
https://codereview.chromium.org/1665553002/diff/120001/components/metrics/leak_detector/leak_detector.cc File components/metrics/leak_detector/leak_detector.cc (right): https://codereview.chromium.org/1665553002/diff/120001/components/metrics/leak_detector/leak_detector.cc#newcode47 components/metrics/leak_detector/leak_detector.cc:47: class MallocHookDisabler { On 2016/03/01 18:54:37, Primiano (throttled til ...
4 years, 9 months ago (2016-03-01 19:09:53 UTC) #32
Simon Que
+llozano Luis, is it safe to call dl_iterate_phdr() to get the Chrome binary mapping info ...
4 years, 9 months ago (2016-03-01 19:12:41 UTC) #34
llozano
On 2016/03/01 19:12:41, Simon Que wrote: > +llozano > > Luis, is it safe to ...
4 years, 9 months ago (2016-03-01 19:43:13 UTC) #35
Primiano Tucci (use gerrit)
Ok, so from the base/allocator viewpoint I think this is ok if we make the ...
4 years, 9 months ago (2016-03-01 21:10:28 UTC) #36
Simon Que
Re: thread safety in the hook functions: you have a valid point. I could just ...
4 years, 9 months ago (2016-03-02 06:25:09 UTC) #37
Primiano Tucci (use gerrit)
> Re: thread safety in the hook functions: you have a valid point. Just to ...
4 years, 9 months ago (2016-03-02 06:39:54 UTC) #38
Simon Que
On 2016/03/02 06:39:54, Primiano (throttled til Mar 4) wrote: > > Re: thread safety in ...
4 years, 9 months ago (2016-03-02 08:52:40 UTC) #39
Primiano Tucci (use gerrit)
Ok let's do this let'd discuss the major things first and leave the other things ...
4 years, 9 months ago (2016-03-02 18:13:27 UTC) #40
Simon Que
We probably don't need it. I'm not sure if there's a thread-safe way to check ...
4 years, 9 months ago (2016-03-02 18:45:56 UTC) #41
Primiano Tucci (use gerrit)
this is the thing I don't get. why do you need to read the value ...
4 years, 9 months ago (2016-03-02 19:06:36 UTC) #42
Simon Que
In case another module comes along and attempts to register another pair of hook functions, ...
4 years, 9 months ago (2016-03-02 19:10:14 UTC) #43
Primiano Tucci (use gerrit)
On 2016/03/02 19:10:14, Simon Que wrote: > In case another module comes along and attempts ...
4 years, 9 months ago (2016-03-02 19:56:16 UTC) #44
Simon Que
On 2016/03/02 19:56:16, Primiano (throttled til Mar 4) wrote: > On 2016/03/02 19:10:14, Simon Que ...
4 years, 9 months ago (2016-03-02 21:56:24 UTC) #45
Primiano Tucci (use gerrit)
base/allocator looks way better, thanks. There are just some comments left pending. Just don't know ...
4 years, 9 months ago (2016-03-02 22:16:11 UTC) #46
Simon Que
https://codereview.chromium.org/1665553002/diff/160001/base/allocator/allocator_extension.cc File base/allocator/allocator_extension.cc (right): https://codereview.chromium.org/1665553002/diff/160001/base/allocator/allocator_extension.cc#newcode51 base/allocator/allocator_extension.cc:51: bool RemoveHooks(AllocHookFunc alloc_hook, FreeHookFunc free_hook) { On 2016/03/02 22:16:11, ...
4 years, 9 months ago (2016-03-02 22:35:25 UTC) #47
Primiano Tucci (use gerrit)
//base/allocator/ LGTM Let me know if you want me to look at the rest or ...
4 years, 9 months ago (2016-03-02 22:46:15 UTC) #48
Simon Que
On 2016/03/02 22:46:15, Primiano (throttled til Mar 4) wrote: > //base/allocator/ LGTM > > Let ...
4 years, 9 months ago (2016-03-02 22:47:35 UTC) #49
Primiano Tucci (use gerrit)
Some comments here. Sorry for the delay, I am In a conference, will finish and ...
4 years, 9 months ago (2016-03-03 16:23:44 UTC) #50
Primiano Tucci (use gerrit)
Some final comments inline. I think I understand what you are doing here, but my ...
4 years, 9 months ago (2016-03-03 17:51:30 UTC) #51
Simon Que
https://codereview.chromium.org/1665553002/diff/200001/components/metrics/leak_detector/leak_detector.cc File components/metrics/leak_detector/leak_detector.cc (right): https://codereview.chromium.org/1665553002/diff/200001/components/metrics/leak_detector/leak_detector.cc#newcode62 components/metrics/leak_detector/leak_detector.cc:62: static base::allocator::AllocHookFunc alloc_hook_; On 2016/03/03 16:23:44, Primiano (throttled til ...
4 years, 9 months ago (2016-03-04 01:59:18 UTC) #52
Simon Que
On 2016/03/03 17:51:30, Primiano (throttled til Mar 4) wrote: > Some final comments inline. > ...
4 years, 9 months ago (2016-03-04 02:15:36 UTC) #53
Simon Que
On 2016/03/04 02:15:36, Simon Que wrote: > On 2016/03/03 17:51:30, Primiano (throttled til Mar 4) ...
4 years, 9 months ago (2016-03-04 02:48:47 UTC) #54
Simon Que
https://codereview.chromium.org/1665553002/diff/200001/components/metrics/leak_detector/leak_detector.cc File components/metrics/leak_detector/leak_detector.cc (right): https://codereview.chromium.org/1665553002/diff/200001/components/metrics/leak_detector/leak_detector.cc#newcode62 components/metrics/leak_detector/leak_detector.cc:62: static base::allocator::AllocHookFunc alloc_hook_; On 2016/03/03 16:23:44, Primiano (throttled til ...
4 years, 9 months ago (2016-03-04 02:55:19 UTC) #55
Primiano Tucci (use gerrit)
> Re-entrance prevention is not practical because it interferes with the deterministic sampling scheme. Right ...
4 years, 9 months ago (2016-03-04 06:57:35 UTC) #56
Primiano Tucci (use gerrit)
On 2016/03/04 02:48:47, Simon Que wrote: > BTW, would you like to discuss this in ...
4 years, 9 months ago (2016-03-04 16:03:56 UTC) #57
Simon Que
I've updated this CL based on my discussion with Primiano. PTAL.
4 years, 9 months ago (2016-03-11 06:38:33 UTC) #58
Simon Que
Adding Alexei and Ilya to review changes to chrome/browser/metrics.
4 years, 9 months ago (2016-03-11 06:40:38 UTC) #60
Primiano Tucci (use gerrit)
I'm a bit short of bandwidth today due to unexpected fires. I had a quick ...
4 years, 9 months ago (2016-03-11 12:10:17 UTC) #61
Simon Que
On 2016/03/11 12:10:17, Primiano wrote: > I'm a bit short of bandwidth today due to ...
4 years, 9 months ago (2016-03-11 21:21:34 UTC) #62
Will Harris
https://codereview.chromium.org/1665553002/diff/260001/components/metrics/leak_detector/leak_detector.h File components/metrics/leak_detector/leak_detector.h (right): https://codereview.chromium.org/1665553002/diff/260001/components/metrics/leak_detector/leak_detector.h#newcode37 components/metrics/leak_detector/leak_detector.h:37: // This class is thread-safe as it uses locks ...
4 years, 9 months ago (2016-03-12 01:44:22 UTC) #63
Simon Que
https://codereview.chromium.org/1665553002/diff/260001/components/metrics/leak_detector/leak_detector.h File components/metrics/leak_detector/leak_detector.h (right): https://codereview.chromium.org/1665553002/diff/260001/components/metrics/leak_detector/leak_detector.h#newcode37 components/metrics/leak_detector/leak_detector.h:37: // This class is thread-safe as it uses locks ...
4 years, 9 months ago (2016-03-14 19:17:01 UTC) #64
Ilya Sherman
Just looked at leak_detector_controller.{h, cc}. Those files LGTM. Please let me know if you'd like ...
4 years, 9 months ago (2016-03-14 22:38:07 UTC) #65
Will Harris
https://codereview.chromium.org/1665553002/diff/300001/components/metrics/leak_detector/leak_detector.cc File components/metrics/leak_detector/leak_detector.cc (right): https://codereview.chromium.org/1665553002/diff/300001/components/metrics/leak_detector/leak_detector.cc#newcode51 components/metrics/leak_detector/leak_detector.cc:51: MappingInfo* mapping = static_cast<MappingInfo*>(data); reinterpret_cast for pointers https://codereview.chromium.org/1665553002/diff/300001/components/metrics/leak_detector/leak_detector.cc#newcode118 components/metrics/leak_detector/leak_detector.cc:118: ...
4 years, 9 months ago (2016-03-15 04:13:35 UTC) #66
Simon Que
https://codereview.chromium.org/1665553002/diff/300001/components/metrics/leak_detector/leak_detector.cc File components/metrics/leak_detector/leak_detector.cc (right): https://codereview.chromium.org/1665553002/diff/300001/components/metrics/leak_detector/leak_detector.cc#newcode51 components/metrics/leak_detector/leak_detector.cc:51: MappingInfo* mapping = static_cast<MappingInfo*>(data); On 2016/03/15 04:13:35, Will Harris ...
4 years, 9 months ago (2016-03-15 06:39:32 UTC) #67
Will Harris
lgtm. thanks for patience while reviewing. https://codereview.chromium.org/1665553002/diff/300001/components/metrics/leak_detector/leak_detector.cc File components/metrics/leak_detector/leak_detector.cc (right): https://codereview.chromium.org/1665553002/diff/300001/components/metrics/leak_detector/leak_detector.cc#newcode236 components/metrics/leak_detector/leak_detector.cc:236: GetReportsForObservers(leak_reports, &leak_reports_for_observers); On ...
4 years, 9 months ago (2016-03-15 06:49:43 UTC) #68
Primiano Tucci (use gerrit)
Apologies for the lateness. I join the LGTM train with few minor comments. I think ...
4 years, 9 months ago (2016-03-15 11:49:24 UTC) #69
Simon Que
https://codereview.chromium.org/1665553002/diff/340001/components/metrics/leak_detector/leak_detector.cc File components/metrics/leak_detector/leak_detector.cc (right): https://codereview.chromium.org/1665553002/diff/340001/components/metrics/leak_detector/leak_detector.cc#newcode171 components/metrics/leak_detector/leak_detector.cc:171: DCHECK(thread_checker_.CalledOnValidThread()); On 2016/03/15 11:49:24, Primiano wrote: > I don't ...
4 years, 9 months ago (2016-03-15 18:33:42 UTC) #70
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1665553002/360001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1665553002/360001
4 years, 9 months ago (2016-03-15 18:34:13 UTC) #73
commit-bot: I haz the power
Committed patchset #19 (id:360001)
4 years, 9 months ago (2016-03-15 19:55:27 UTC) #75
commit-bot: I haz the power
4 years, 9 months ago (2016-03-15 19:56:53 UTC) #77
Message was sent while issue was closed.
Patchset 19 (id:??) landed as
https://crrev.com/be8dae533a69fc2c2a71a03193bc59de7570999a
Cr-Commit-Position: refs/heads/master@{#381293}

Powered by Google App Engine
This is Rietveld 408576698