Changeset 167883 in webkit


Ignore:
Timestamp:
Apr 28, 2014 4:10:31 AM (10 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Crash in debug build with removing windowed plugin child widgets from the view
https://bugs.webkit.org/show_bug.cgi?id=132252

Reviewed by Philippe Normand.

It crashes due to an assert in HashTable that checks the iterators
validity. The problem is that we are iterating the children map
and the callback called on every iteration might modify the map,
making the iterators invalid. This happens when the WebView is
destroyed, GtkContainer calls gtk_container_foreach() with
gtk_widget_destroy as callback. When a widget inside a container
is destroyed, it's removed from the container, and in our case,
the child widget is removed from the map. This fixes several
crashes when running layout tests in debug bot.

  • UIProcess/API/gtk/WebKitWebViewBase.cpp:

(webkitWebViewBaseContainerForall): Use copyKeysToVector() instead
of using a range iterator for the map keys and check in every
iteration that the child widget from the keys vector is still
present in the map before calling the callback.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r167873 r167883  
     12014-04-28  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Crash in debug build with removing windowed plugin child widgets from the view
     4        https://bugs.webkit.org/show_bug.cgi?id=132252
     5
     6        Reviewed by Philippe Normand.
     7
     8        It crashes due to an assert in HashTable that checks the iterators
     9        validity. The problem is that we are iterating the children map
     10        and the callback called on every iteration might modify the map,
     11        making the iterators invalid. This happens when the WebView is
     12        destroyed, GtkContainer calls gtk_container_foreach() with
     13        gtk_widget_destroy as callback. When a widget inside a container
     14        is destroyed, it's removed from the container, and in our case,
     15        the child widget is removed from the map. This fixes several
     16        crashes when running layout tests in debug bot.
     17
     18        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
     19        (webkitWebViewBaseContainerForall): Use copyKeysToVector() instead
     20        of using a range iterator for the map keys and check in every
     21        iteration that the child widget from the keys vector is still
     22        present in the map before calling the callback.
     23
    1242014-04-28  Carlos Garcia Campos  <cgarcia@igalia.com>
    225
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp

    r167195 r167883  
    364364    WebKitWebViewBasePrivate* priv = webView->priv;
    365365
    366     for (const auto& widget : priv->children.keys())
    367         (*callback)(widget, callbackData);
     366    Vector<GtkWidget*> children;
     367    copyKeysToVector(priv->children, children);
     368    for (const auto& child : children) {
     369        if (priv->children.contains(child))
     370            (*callback)(child, callbackData);
     371    }
    368372
    369373    if (includeInternals && priv->inspectorView)
Note: See TracChangeset for help on using the changeset viewer.