MacViews: Use after free occurs if a BridgedNativeWidget with capture is destroyed. |
||
Issue description
<b>Version: <Kenneth, what is the frequency?></b>
OS: 53.0.2775.0
What steps will reproduce the problem?
The following unit test leads to a crash.
TEST_F(WidgetTest, SetWindowCapture) {
Widget* widget = CreateTopLevelNativeWidget();
widget->Show();
widget->native_widget_private()->SetCapture();
EXPECT_TRUE(widget->HasCapture());
widget->CloseNow();
}
The crash occurs at the closeNow() call. Here is how the flow progresses.
NativeWidgetMac::CloseNow()->~BridgedNativeWidget()->~CocoaMouseCapture()->~ActiveEventTap()->BridgedNativeWidget::OnMouseCaptureLost.
This accessess native_widget_mac_, which has already been destroyed via ~BridgedNativeWidget()->BridgedNativeWidget::OnWindowWillClose().
,
Jun 28 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/dc6e0034dc928d3c10ee923284d0f10781975280 commit dc6e0034dc928d3c10ee923284d0f10781975280 Author: karandeepb <karandeepb@chromium.org> Date: Tue Jun 28 02:49:10 2016 MacViews: Explicitly release mouse capture in BridgedNativeWidget::OnWindowWillClose(). Currently, if a BridgedNativeWidget with mouse capture is destroyed, it gets a OnMouseCaptureLost callback from its CocoaMouseCapture member instance. BridgedNativeWidget::OnMouseCaptureLost accesses native_widget_mac_ which has already been destroyed, leading to a use after crash. This CL resolves the crash by explicitly releasing mouse capture in BridgedNativeWidget::OnWindowWillClose(). Also added tests which crash on MacViews for the current master, to test the various codepaths possible when a window is closed. BUG= 622201 Review-Url: https://codereview.chromium.org/2090003002 Cr-Commit-Position: refs/heads/master@{#402385} [modify] https://crrev.com/dc6e0034dc928d3c10ee923284d0f10781975280/ui/views/cocoa/bridged_native_widget.mm [modify] https://crrev.com/dc6e0034dc928d3c10ee923284d0f10781975280/ui/views/widget/widget_interactive_uitest.cc
,
Jun 28 2016
|
||
►
Sign in to add a comment |
||
Comment 1 by tapted@chromium.org
, Jun 22 2016