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

Issue 2641983003: Reland Fix MenuController Heap-use-after-free (Closed)

Created:
3 years, 11 months ago by jonross
Modified:
3 years, 11 months ago
Reviewers:
sky
CC:
chromium-reviews, tfarina
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Reland Fix MenuController Heap-use-after-free The original patch fixed a heap-use-after-free, but exposed a memory leak. MenuController applies a ref to ViewsDelegate, in order to prevent Chrome from shutting down while a menu is open. This ref is released as the menu is closing. However it is possible for the release of the ref to lead to Chrome shutting down immediately. During this MenuController is deleted. However it was possible that MenuController would access the heap as the stack collapsed. This change updates the menu closing process to detect the deletion and to shutdown cleanly. However it is possible that during drag-and-drop that two MenuControllers are being used. The drag-and-drop can be caused by once, which is replaced by a different active instance. The active instance can be deleted first. Upon the completion of drag-and-drop the remaining MenuController must notify its delegate, which can outlive it. So that associated cleanup can be done. This change updates the ExitAsyncRun to cache heap variables needed by the longer life delegate. So that it can still be called for cleanup if the MenuController has been deleted. This relands https://codereview.chromium.org/2636293002/ This reverts commit cd4f55690437f7c40bfa710586781ec316cc889e. TEST=MenuControllerTest.DestroyedDuringViewsRelease, BookmarkBarViewTest7.DNDToDifferentMenu, BookmarkBarViewTest8.DNDBackToOriginatingMenu BUG=682109, 681462 Review-Url: https://codereview.chromium.org/2641983003 Cr-Commit-Position: refs/heads/master@{#444580} Committed: https://chromium.googlesource.com/chromium/src/+/4a3f02d18631fc413399a5e058b89f34628826d9

Patch Set 1 #

Patch Set 2 : Apply Fix #

Unified diffs Side-by-side diffs Delta from patch set Stats (+68 lines, -1 line) Patch
M ui/views/controls/menu/menu_controller.cc View 1 2 chunks +9 lines, -1 line 0 comments Download
M ui/views/controls/menu/menu_controller_unittest.cc View 6 chunks +59 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (4 generated)
jonross
Hey sky@, This is a follow up to the revert patch from last night. First ...
3 years, 11 months ago (2017-01-18 22:43:15 UTC) #2
sky
LGTM
3 years, 11 months ago (2017-01-18 23:36:10 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2641983003/20001
3 years, 11 months ago (2017-01-18 23:55:46 UTC) #5
commit-bot: I haz the power
3 years, 11 months ago (2017-01-19 01:07:32 UTC) #8
Message was sent while issue was closed.
Committed patchset #2 (id:20001) as
https://chromium.googlesource.com/chromium/src/+/4a3f02d18631fc413399a5e058b8...

Powered by Google App Engine
This is Rietveld 408576698