Title: [91062] trunk/Source/WebKit2
Revision
91062
Author
carlo...@webkit.org
Date
2011-07-15 03:40:36 -0700 (Fri, 15 Jul 2011)

Log Message

Reviewed by Martin Robinson.

[GTK] Install a custom X error handler in plugin process
https://bugs.webkit.org/show_bug.cgi?id=63248

Some plugins, specially flash, can cause X errors that when
handled by the default X error handler (or the GDK one) abort the
process. Since we don't want to crash due to buggy plugins, we
install a custom error handler to show a warning when a X error
happens without aborting.

* PluginProcess/gtk/PluginProcessMainGtk.cpp:
(WebKit::webkitgtkXError):
(WebKit::PluginProcessMainGtk):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (91061 => 91062)


--- trunk/Source/WebKit2/ChangeLog	2011-07-15 10:06:31 UTC (rev 91061)
+++ trunk/Source/WebKit2/ChangeLog	2011-07-15 10:40:36 UTC (rev 91062)
@@ -1,3 +1,20 @@
+2011-07-15  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [GTK] Install a custom X error handler in plugin process
+        https://bugs.webkit.org/show_bug.cgi?id=63248
+
+        Some plugins, specially flash, can cause X errors that when
+        handled by the default X error handler (or the GDK one) abort the
+        process. Since we don't want to crash due to buggy plugins, we
+        install a custom error handler to show a warning when a X error
+        happens without aborting.
+
+        * PluginProcess/gtk/PluginProcessMainGtk.cpp:
+        (WebKit::webkitgtkXError):
+        (WebKit::PluginProcessMainGtk):
+
 2011-07-14  Carlos Garcia Campos  <cgar...@igalia.com>
 
         Reviewed by Anders Carlsson.

Modified: trunk/Source/WebKit2/PluginProcess/gtk/PluginProcessMainGtk.cpp (91061 => 91062)


--- trunk/Source/WebKit2/PluginProcess/gtk/PluginProcessMainGtk.cpp	2011-07-15 10:06:31 UTC (rev 91061)
+++ trunk/Source/WebKit2/PluginProcess/gtk/PluginProcessMainGtk.cpp	2011-07-15 10:40:36 UTC (rev 91062)
@@ -28,12 +28,27 @@
 
 #include "PluginProcess.h"
 #include <WebKit2/RunLoop.h>
+#include <gdk/gdkx.h>
 #include <gtk/gtk.h>
 #include <runtime/InitializeThreading.h>
 #include <wtf/Threading.h>
 
 namespace WebKit {
 
+static int webkitgtkXError(Display* xdisplay, XErrorEvent* error)
+{
+    gchar errorMessage[64];
+    XGetErrorText(xdisplay, error->error_code, errorMessage, 63);
+    g_warning("The program '%s' received an X Window System error.\n"
+              "This probably reflects a bug in a browser plugin.\n"
+              "The error was '%s'.\n"
+              "  (Details: serial %ld error_code %d request_code %d minor_code %d)\n",
+              g_get_prgname(), errorMessage,
+              error->serial, error->error_code,
+              error->request_code, error->minor_code);
+    return 0;
+}
+
 WK_EXPORT int PluginProcessMainGtk(int argc, char* argv[])
 {
     ASSERT(argc == 2);
@@ -44,6 +59,11 @@
     WTF::initializeMainThread();
     RunLoop::initializeMainRunLoop();
 
+    // Plugins can produce X errors that are handled by the GDK X error handler, which
+    // exits the process. Since we don't want to crash due to plugin bugs, we install a
+    // custom error handler to show a warning when a X error happens without aborting.
+    XSetErrorHandler(webkitgtkXError);
+
     int socket = atoi(argv[1]);
     WebKit::PluginProcess::shared().initialize(socket, RunLoop::main());
     RunLoop::run();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to