summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 01:56:27 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 01:56:27 +0000
commitf658af8bb836debbac7ca687634792d9dc6b9f87 (patch)
treef69027acb8331a93c3db63ee5017509f6b3aacd2 /app
parenta551ebd84a64c2723cae1b1c48eef602f9c3b44b (diff)
downloadchromium_src-f658af8bb836debbac7ca687634792d9dc6b9f87.zip
chromium_src-f658af8bb836debbac7ca687634792d9dc6b9f87.tar.gz
chromium_src-f658af8bb836debbac7ca687634792d9dc6b9f87.tar.bz2
Linux: Catch X errors and force a crash.
BUG=45020 TEST=See http://crosbug.com/3487 Review URL: http://codereview.chromium.org/2716007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49488 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r--app/x11_util.cc18
-rw-r--r--app/x11_util.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/app/x11_util.cc b/app/x11_util.cc
index 78e09fc..934e824 100644
--- a/app/x11_util.cc
+++ b/app/x11_util.cc
@@ -52,8 +52,26 @@ CachedPictFormats* get_cached_pict_formats() {
// Maximum number of CachedPictFormats we keep around.
const size_t kMaxCacheSize = 5;
+int X11ErrorHandler(Display* d, XErrorEvent* e) {
+ LOG(FATAL) << "X Error detected: serial " << e->serial
+ << " error_code " << static_cast<unsigned int>(e->error_code)
+ << " request_code " << static_cast<unsigned int>(e->request_code)
+ << " minor_code " << static_cast<unsigned int>(e->minor_code);
+ return 0;
+}
+
+int X11IOErrorHandler(Display* d) {
+ LOG(FATAL) << "X IO Error detected";
+ return 0;
+}
+
} // namespace
+void SetX11ErrorHandlers() {
+ XSetErrorHandler(X11ErrorHandler);
+ XSetIOErrorHandler(X11IOErrorHandler);
+}
+
bool XDisplayExists() {
return (gdk_display_get_default() != NULL);
}
diff --git a/app/x11_util.h b/app/x11_util.h
index 5c202f3..b85061c 100644
--- a/app/x11_util.h
+++ b/app/x11_util.h
@@ -170,6 +170,9 @@ void GrabWindowSnapshot(GtkWindow* gdk_window,
// Change desktop for |window| to the desktop of |destination| window.
bool ChangeWindowDesktop(XID window, XID destination);
+// Sets the X Error Handlers so we can catch X errors and crash.
+void SetX11ErrorHandlers();
+
} // namespace x11_util
#endif // APP_X11_UTIL_H_