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

Issue 1221173003: [Mac] Inform reference counted objects that hold a weak Browser* when the Browser is being destroye… (Closed)

Created:
5 years, 5 months ago by jackhou1
Modified:
5 years, 5 months ago
CC:
chromium-reviews, asanka, extensions-reviews_chromium.org, benjhayden+dwatch_chromium.org, tfarina, noyau+watch_chromium.org, chromium-apps-reviews_chromium.org, chrome-apps-syd-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Mac] Inform reference counted objects that hold a weak Browser* when the Browser is being destroyed. In 10.10, when ToolbarController's NSView is loaded, NSNib creates a dictionary that retains ToolbarController. This dictionary is later autoreleased. This causes ToolbarController to briefly outlive Browser when the BrowserWindow closes. Objects whose lifetime is tied to ToolbarController may hold a weak Browser* and attempt to access it during destruction resulting in a use-after-free. This can also happen with other similar reference-counted objects like WrenchMenuController. This CL adds -browserWillBeDestroyed to many of these objects so they can invalidate their Browser* and pass the notification onto other similar objects. Any use-after-free becomes a null pointer dereference which we can detect and fix. BUG=506745, 505710 Committed: https://crrev.com/0e97f8a8934f34fb6f5aba7214eb8470862c52b6 Cr-Commit-Position: refs/heads/master@{#338198}

Patch Set 1 #

Patch Set 2 : Add unit test for WrenchMenuController. #

Patch Set 3 : Fix compile. #

Patch Set 4 : Call browserWillBeDestroyed in unit test. #

Patch Set 5 : Remove dealloc override. #

Total comments: 20

Patch Set 6 : Address comments. #

Patch Set 7 : Merge dealloc into browserWillBeDestroyed. #

Patch Set 8 : Fix ToolbarActionsBar tests. #

Total comments: 14

Patch Set 9 : Address comments. #

Patch Set 10 : Fix up BookmarkBarController tests. #

Patch Set 11 : Keep -[BookmarBarController dealloc] instead of changing all the tests. #

Total comments: 4

Patch Set 12 : Add HasWeakBrowserPointer protocol. Allow -dealloc without preceding -browserWillBeDestroyed. #

Total comments: 10

Patch Set 13 : Address comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+235 lines, -106 lines) Patch
M chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +8 lines, -6 lines 0 comments Download
M chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm View 1 2 3 4 5 6 7 8 9 10 2 chunks +6 lines, -1 line 0 comments Download
M chrome/browser/ui/cocoa/browser_window_controller.mm View 1 2 3 4 5 6 7 8 9 10 11 4 chunks +18 lines, -6 lines 0 comments Download
M chrome/browser/ui/cocoa/download/download_shelf_controller.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -5 lines 0 comments Download
M chrome/browser/ui/cocoa/download/download_shelf_controller.mm View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +17 lines, -17 lines 0 comments Download
M chrome/browser/ui/cocoa/download/download_shelf_controller_unittest.mm View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +1 line, -2 lines 0 comments Download
M chrome/browser/ui/cocoa/extensions/browser_actions_controller.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +3 lines, -1 line 0 comments Download
M chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +11 lines, -3 lines 0 comments Download
M chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +6 lines, -1 line 0 comments Download
A chrome/browser/ui/cocoa/has_weak_browser_pointer.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +22 lines, -0 lines 0 comments Download
M chrome/browser/ui/cocoa/profiles/avatar_base_controller.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +6 lines, -1 line 0 comments Download
M chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h View 1 2 3 4 5 2 chunks +0 lines, -10 lines 0 comments Download
M chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.mm View 1 chunk +1 line, -3 lines 0 comments Download
M chrome/browser/ui/cocoa/tabs/tab_strip_controller.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +4 lines, -3 lines 0 comments Download
M chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +7 lines, -1 line 0 comments Download
M chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +5 lines, -2 lines 0 comments Download
M chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.mm View 1 2 3 4 5 6 7 8 1 chunk +7 lines, -0 lines 0 comments Download
M chrome/browser/ui/cocoa/toolbar/toolbar_controller.h View 1 2 3 4 5 6 7 8 9 10 11 5 chunks +4 lines, -5 lines 0 comments Download
M chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm View 1 2 3 4 5 6 7 8 9 10 11 12 5 chunks +45 lines, -29 lines 0 comments Download
M chrome/browser/ui/cocoa/toolbar/toolbar_controller_unittest.mm View 1 2 3 4 5 6 7 8 4 chunks +5 lines, -7 lines 0 comments Download
M chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +3 lines, -1 line 0 comments Download
M chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.mm View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +19 lines, -0 lines 0 comments Download
M chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller_unittest.mm View 1 2 3 2 chunks +29 lines, -0 lines 0 comments Download
M chrome/chrome_browser_ui.gypi View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 23 (5 generated)
jackhou1
tapted, WDYT? Main changes in BrowserWindowController, ToolbarController, WrenchMenuController, in that order.
5 years, 5 months ago (2015-07-06 06:58:08 UTC) #2
tapted
Just had a quick skim. I suspect this is what is needed. Do we have ...
5 years, 5 months ago (2015-07-06 07:26:18 UTC) #3
jackhou1
>Do we have something more concrete to say about the particular failure on 10.10. >That ...
5 years, 5 months ago (2015-07-07 03:27:27 UTC) #4
tapted
Maybe hit up rsesek for a second opinion too - I'm still a bit of ...
5 years, 5 months ago (2015-07-07 04:25:59 UTC) #5
jackhou1
https://codereview.chromium.org/1221173003/diff/140001/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm File chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm (right): https://codereview.chromium.org/1221173003/diff/140001/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm#newcode356 chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm:356: - (void)dealloc { On 2015/07/07 04:25:59, tapted wrote: > ...
5 years, 5 months ago (2015-07-07 08:33:06 UTC) #6
tapted
lgtm but +rsesek for a second opinion and since it's a bit of a curly ...
5 years, 5 months ago (2015-07-07 12:45:11 UTC) #8
Robert Sesek
+erikchen who has been working to fix browser tests like https://codereview.chromium.org/1229473002/ It seems like the ...
5 years, 5 months ago (2015-07-07 15:51:04 UTC) #10
tapted
My perspective: after many days of head scratching while writing the tests for ui/app_list/cocoa, I ...
5 years, 5 months ago (2015-07-08 00:11:54 UTC) #11
erikchen
On 2015/07/08 00:11:54, tapted wrote: > My perspective: after many days of head scratching while ...
5 years, 5 months ago (2015-07-08 01:02:47 UTC) #12
erikchen
https://codereview.chromium.org/1221173003/diff/190001/chrome/browser/ui/cocoa/browser_window_controller.mm File chrome/browser/ui/cocoa/browser_window_controller.mm (right): https://codereview.chromium.org/1221173003/diff/190001/chrome/browser/ui/cocoa/browser_window_controller.mm#newcode440 chrome/browser/ui/cocoa/browser_window_controller.mm:440: // Inform reference counted objects that the Browser will ...
5 years, 5 months ago (2015-07-08 01:18:03 UTC) #13
jackhou1
https://codereview.chromium.org/1221173003/diff/190001/chrome/browser/ui/cocoa/browser_window_controller.mm File chrome/browser/ui/cocoa/browser_window_controller.mm (right): https://codereview.chromium.org/1221173003/diff/190001/chrome/browser/ui/cocoa/browser_window_controller.mm#newcode440 chrome/browser/ui/cocoa/browser_window_controller.mm:440: // Inform reference counted objects that the Browser will ...
5 years, 5 months ago (2015-07-08 07:02:12 UTC) #14
erikchen
lgtm with nits. https://codereview.chromium.org/1221173003/diff/210001/chrome/browser/ui/cocoa/download/download_shelf_controller.mm File chrome/browser/ui/cocoa/download/download_shelf_controller.mm (right): https://codereview.chromium.org/1221173003/diff/210001/chrome/browser/ui/cocoa/download/download_shelf_controller.mm#newcode154 chrome/browser/ui/cocoa/download/download_shelf_controller.mm:154: [[self animatableView] stopAnimation]; this logic looks ...
5 years, 5 months ago (2015-07-08 18:02:17 UTC) #15
Robert Sesek
This approah is fine, so LG. Though you could potentially also do this with a ...
5 years, 5 months ago (2015-07-08 22:15:18 UTC) #16
jackhou1
On 2015/07/08 22:15:18, Robert Sesek wrote: > This approah is fine, so LG. Though you ...
5 years, 5 months ago (2015-07-09 03:48:03 UTC) #17
Robert Sesek
On 2015/07/09 03:48:03, jackhou1 wrote: > On 2015/07/08 22:15:18, Robert Sesek wrote: > > This ...
5 years, 5 months ago (2015-07-09 15:13:09 UTC) #18
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1221173003/230001
5 years, 5 months ago (2015-07-09 23:37:05 UTC) #21
commit-bot: I haz the power
Committed patchset #13 (id:230001)
5 years, 5 months ago (2015-07-10 00:32:36 UTC) #22
commit-bot: I haz the power
5 years, 5 months ago (2015-07-10 00:33:30 UTC) #23
Message was sent while issue was closed.
Patchset 13 (id:??) landed as
https://crrev.com/0e97f8a8934f34fb6f5aba7214eb8470862c52b6
Cr-Commit-Position: refs/heads/master@{#338198}

Powered by Google App Engine
This is Rietveld 408576698