Bug 1271100 - work around race in system Cairo's XShm usage. r=karlt
authorLee Salzman <lsalzman@mozilla.com>
Tue, 29 Nov 2016 23:01:13 -0500
changeset 324769 f78f86eaba8dfba74c41d150bf166abf0e17e7ff
parent 324768 18cd502c7f016e863db54669cb26d1013412f3dd
child 324770 466d794c37a1275035ab51f78f57cf79efcd8260
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerskarlt
bugs1271100
milestone53.0a1
Bug 1271100 - work around race in system Cairo's XShm usage. r=karlt MozReview-Commit-ID: VGee6ungCz
widget/gtk/mozgtk/mozgtk.c
--- a/widget/gtk/mozgtk/mozgtk.c
+++ b/widget/gtk/mozgtk/mozgtk.c
@@ -606,8 +606,27 @@ STUB(gdk_window_set_back_pixmap)
 STUB(gdk_x11_colormap_foreign_new)
 STUB(gdk_x11_colormap_get_xcolormap)
 STUB(gdk_x11_drawable_get_xdisplay)
 STUB(gdk_x11_drawable_get_xid)
 STUB(gdk_x11_window_get_drawable_impl)
 STUB(gdkx_visual_get)
 STUB(gtk_object_get_type)
 #endif
+
+#ifndef GTK3_SYMBOLS
+// Only define the following workaround when using GTK3, which we detect
+// by checking if GTK3 stubs are not provided.
+#include <X11/Xlib.h>
+// Bug 1271100
+// We need to trick system Cairo into not using the XShm extension due to
+// a race condition in it that results in frequent BadAccess errors. Cairo
+// relies upon XShmQueryExtension to initially detect if XShm is available.
+// So we define our own stub that always indicates XShm not being present.
+// mozgtk loads before libXext/libcairo and so this stub will take priority.
+// Our tree usage goes through xcb and remains unaffected by this.
+MOZ_EXPORT Bool
+XShmQueryExtension(Display* aDisplay)
+{
+  return False;
+}
+#endif
+