Title: [211145] trunk/Source
Revision
211145
Author
[email protected]
Date
2017-01-25 08:54:28 -0800 (Wed, 25 Jan 2017)

Log Message

[GTK] UIProcess from WebKitGtk+ 2.15.x SIGSEGVs because of X Error BadDamage in WebKit::AcceleratedBackingStoreX11::update(WebKit::LayerTreeContext const&) () at Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.cpp:145
https://bugs.webkit.org/show_bug.cgi?id=165656

Reviewed by Michael Catanzaro.

Source/WebCore:

Also return the base error code from PlatformDisplayX11::supportsXDamage().

* platform/graphics/x11/PlatformDisplayX11.cpp:
(WebCore::PlatformDisplayX11::supportsXDamage):
* platform/graphics/x11/PlatformDisplayX11.h:

Source/WebKit2:

We are incorrectly handling BadDamage errors because the BadDamage value we pass to the XErrorTrapper is not
the actual error code used by X11. Since XDamage is an extension, it has its own errors and a base error
code. We need to use the base error code we get when calling XDamageQueryExtension to pass the right error code
to the XErrorTrapper.

* UIProcess/gtk/AcceleratedBackingStoreX11.cpp:
(WebKit::AcceleratedBackingStoreX11::create): Get also the damage base error.
(WebKit::xDamageErrorCode): Helper to get the actual error code.
(WebKit::AcceleratedBackingStoreX11::~AcceleratedBackingStoreX11): Use xDamageErrorCode().
(WebKit::AcceleratedBackingStoreX11::update): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (211144 => 211145)


--- trunk/Source/WebCore/ChangeLog	2017-01-25 16:46:02 UTC (rev 211144)
+++ trunk/Source/WebCore/ChangeLog	2017-01-25 16:54:28 UTC (rev 211145)
@@ -1,5 +1,18 @@
 2017-01-25  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] UIProcess from WebKitGtk+ 2.15.x SIGSEGVs because of X Error BadDamage in WebKit::AcceleratedBackingStoreX11::update(WebKit::LayerTreeContext const&) () at Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.cpp:145
+        https://bugs.webkit.org/show_bug.cgi?id=165656
+
+        Reviewed by Michael Catanzaro.
+
+        Also return the base error code from PlatformDisplayX11::supportsXDamage().
+
+        * platform/graphics/x11/PlatformDisplayX11.cpp:
+        (WebCore::PlatformDisplayX11::supportsXDamage):
+        * platform/graphics/x11/PlatformDisplayX11.h:
+
+2017-01-25  Carlos Garcia Campos  <[email protected]>
+
         Unreviewed. Fix 32 bit build after r211140.
 
         Include glib-object.h instead of forward declaring GType.

Modified: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp (211144 => 211145)


--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp	2017-01-25 16:46:02 UTC (rev 211144)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.cpp	2017-01-25 16:54:28 UTC (rev 211145)
@@ -98,7 +98,7 @@
     return m_supportsXComposite.value();
 }
 
-bool PlatformDisplayX11::supportsXDamage(std::optional<int>& damageEventBase) const
+bool PlatformDisplayX11::supportsXDamage(std::optional<int>& damageEventBase, std::optional<int>& damageErrorBase) const
 {
     if (!m_supportsXDamage) {
         m_supportsXDamage = false;
@@ -106,13 +106,16 @@
         if (m_display) {
             int eventBase, errorBase;
             m_supportsXDamage = XDamageQueryExtension(m_display, &eventBase, &errorBase);
-            if (m_supportsXDamage.value())
+            if (m_supportsXDamage.value()) {
                 m_damageEventBase = eventBase;
+                m_damageErrorBase = errorBase;
+            }
         }
 #endif
     }
 
     damageEventBase = m_damageEventBase;
+    damageErrorBase = m_damageErrorBase;
     return m_supportsXDamage.value();
 }
 

Modified: trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h (211144 => 211145)


--- trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h	2017-01-25 16:46:02 UTC (rev 211144)
+++ trunk/Source/WebCore/platform/graphics/x11/PlatformDisplayX11.h	2017-01-25 16:54:28 UTC (rev 211145)
@@ -43,7 +43,7 @@
 
     Display* native() const { return m_display; }
     bool supportsXComposite() const;
-    bool supportsXDamage(std::optional<int>& damageEventBase) const;
+    bool supportsXDamage(std::optional<int>& damageEventBase, std::optional<int>& damageErrorBase) const;
 
 private:
     Type type() const override { return PlatformDisplay::Type::X11; }
@@ -56,6 +56,7 @@
     mutable std::optional<bool> m_supportsXComposite;
     mutable std::optional<bool> m_supportsXDamage;
     mutable std::optional<int> m_damageEventBase;
+    mutable std::optional<int> m_damageErrorBase;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebKit2/ChangeLog (211144 => 211145)


--- trunk/Source/WebKit2/ChangeLog	2017-01-25 16:46:02 UTC (rev 211144)
+++ trunk/Source/WebKit2/ChangeLog	2017-01-25 16:54:28 UTC (rev 211145)
@@ -1,3 +1,21 @@
+2017-01-25  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] UIProcess from WebKitGtk+ 2.15.x SIGSEGVs because of X Error BadDamage in WebKit::AcceleratedBackingStoreX11::update(WebKit::LayerTreeContext const&) () at Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.cpp:145
+        https://bugs.webkit.org/show_bug.cgi?id=165656
+
+        Reviewed by Michael Catanzaro.
+
+        We are incorrectly handling BadDamage errors because the BadDamage value we pass to the XErrorTrapper is not
+        the actual error code used by X11. Since XDamage is an extension, it has its own errors and a base error
+        code. We need to use the base error code we get when calling XDamageQueryExtension to pass the right error code
+        to the XErrorTrapper.
+
+        * UIProcess/gtk/AcceleratedBackingStoreX11.cpp:
+        (WebKit::AcceleratedBackingStoreX11::create): Get also the damage base error.
+        (WebKit::xDamageErrorCode): Helper to get the actual error code.
+        (WebKit::AcceleratedBackingStoreX11::~AcceleratedBackingStoreX11): Use xDamageErrorCode().
+        (WebKit::AcceleratedBackingStoreX11::update): Ditto.
+
 2017-01-25  Miguel Gomez  <[email protected]>
 
         [GTK] The inspector is broken when AC support is disabled

Modified: trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.cpp (211144 => 211145)


--- trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.cpp	2017-01-25 16:46:02 UTC (rev 211144)
+++ trunk/Source/WebKit2/UIProcess/gtk/AcceleratedBackingStoreX11.cpp	2017-01-25 16:54:28 UTC (rev 211145)
@@ -47,6 +47,7 @@
 namespace WebKit {
 
 static std::optional<int> s_damageEventBase;
+static std::optional<int> s_damageErrorBase;
 
 class XDamageNotifier {
     WTF_MAKE_NONCOPYABLE(XDamageNotifier);
@@ -105,7 +106,7 @@
 std::unique_ptr<AcceleratedBackingStoreX11> AcceleratedBackingStoreX11::create(WebPageProxy& webPage)
 {
     auto& display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay());
-    if (!display.supportsXComposite() || !display.supportsXDamage(s_damageEventBase))
+    if (!display.supportsXComposite() || !display.supportsXDamage(s_damageEventBase, s_damageErrorBase))
         return nullptr;
     return std::unique_ptr<AcceleratedBackingStoreX11>(new AcceleratedBackingStoreX11(webPage));
 }
@@ -115,6 +116,12 @@
 {
 }
 
+static inline unsigned char xDamageErrorCode(unsigned char errorCode)
+{
+    ASSERT(s_damageErrorBase);
+    return static_cast<unsigned>(s_damageErrorBase.value()) + errorCode;
+}
+
 AcceleratedBackingStoreX11::~AcceleratedBackingStoreX11()
 {
     if (!m_surface && !m_damage)
@@ -121,7 +128,7 @@
         return;
 
     Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
-    XErrorTrapper trapper(display, XErrorTrapper::Policy::Crash, { BadDrawable, BadDamage });
+    XErrorTrapper trapper(display, XErrorTrapper::Policy::Crash, { BadDrawable, xDamageErrorCode(BadDamage) });
     if (m_damage) {
         XDamageNotifier::singleton().remove(m_damage.get());
         m_damage.reset();
@@ -138,7 +145,7 @@
     Display* display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native();
 
     if (m_surface) {
-        XErrorTrapper trapper(display, XErrorTrapper::Policy::Crash, { BadDrawable, BadDamage });
+        XErrorTrapper trapper(display, XErrorTrapper::Policy::Crash, { BadDrawable, xDamageErrorCode(BadDamage) });
         if (m_damage) {
             XDamageNotifier::singleton().remove(m_damage.get());
             m_damage.reset();
@@ -158,7 +165,7 @@
     float deviceScaleFactor = m_webPage.deviceScaleFactor();
     size.scale(deviceScaleFactor);
 
-    XErrorTrapper trapper(display, XErrorTrapper::Policy::Crash, { BadDrawable, BadDamage });
+    XErrorTrapper trapper(display, XErrorTrapper::Policy::Crash, { BadDrawable, xDamageErrorCode(BadDamage) });
     ASSERT(downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay()).native() == GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
     GdkVisual* visual = gdk_screen_get_rgba_visual(gdk_screen_get_default());
     if (!visual)

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp (211144 => 211145)


--- trunk/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp	2017-01-25 16:46:02 UTC (rev 211144)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp	2017-01-25 16:54:28 UTC (rev 211145)
@@ -61,8 +61,8 @@
 #if USE(REDIRECTED_XCOMPOSITE_WINDOW)
     if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11) {
         auto& display = downcast<PlatformDisplayX11>(PlatformDisplay::sharedDisplay());
-        std::optional<int> damageBase;
-        if (!display.supportsXComposite() || !display.supportsXDamage(damageBase))
+        std::optional<int> damageBase, errorBase;
+        if (!display.supportsXComposite() || !display.supportsXDamage(damageBase, errorBase))
             setAcceleratedCompositingEnabled(false);
     }
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to