Bug 1726923 - Add Wayland crash handler, r=stransky,emilio
authorRobert Mader <robert.mader@posteo.de>
Tue, 31 Aug 2021 18:27:00 +0000
changeset 590370 8752551766570968812880e167ecfa60be030b02
parent 590369 8421e5cd1793cde94f17c9375f312ead6e4dfad5
child 590371 b2c5ed1aea75d8206e0aea3deddc4f8507b3d3be
push id148908
push userrobert.mader@posteo.de
push dateTue, 31 Aug 2021 18:52:19 +0000
treeherderautoland@b2c5ed1aea75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky, emilio
bugs1726923
milestone93.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1726923 - Add Wayland crash handler, r=stransky,emilio To ensure Wayland protocol errors trigger crash reports. This is inspired by Xwayland, which handles things similarly. Note: in theory there are a few cases we wouldn't need to crash on `wl_log` - but in practice we always want to. Differential Revision: https://phabricator.services.mozilla.com/D123894
widget/gtk/nsWaylandDisplay.cpp
--- a/widget/gtk/nsWaylandDisplay.cpp
+++ b/widget/gtk/nsWaylandDisplay.cpp
@@ -319,16 +319,20 @@ void nsWaylandDisplay::WaitForSyncEnd() 
     }
   }
 }
 
 bool nsWaylandDisplay::Matches(wl_display* aDisplay) {
   return mThreadId == PR_GetCurrentThread() && aDisplay == mDisplay;
 }
 
+static void WlCrashHandler(const char* format, va_list args) {
+  MOZ_CRASH_UNSAFE(g_strdup_vprintf(format, args));
+}
+
 nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay)
     : mThreadId(PR_GetCurrentThread()),
       mDisplay(aDisplay),
       mEventQueue(nullptr),
       mDataDeviceManager(nullptr),
       mCompositor(nullptr),
       mSubcompositor(nullptr),
       mShm(nullptr),
@@ -336,16 +340,20 @@ nsWaylandDisplay::nsWaylandDisplay(wl_di
       mPrimarySelectionDeviceManagerGtk(nullptr),
       mPrimarySelectionDeviceManagerZwpV1(nullptr),
       mIdleInhibitManager(nullptr),
       mRelativePointerManager(nullptr),
       mPointerConstraints(nullptr),
       mViewporter(nullptr),
       mDmabuf(nullptr),
       mExplicitSync(false) {
+  // GTK sets the log handler on display creation, thus we overwrite it here
+  // in a similar fashion
+  wl_log_set_handler_client(WlCrashHandler);
+
   wl_registry* registry = wl_display_get_registry(mDisplay);
   wl_registry_add_listener(registry, &registry_listener, this);
   if (!NS_IsMainThread()) {
     mEventQueue = wl_display_create_queue(mDisplay);
     wl_proxy_set_queue((struct wl_proxy*)registry, mEventQueue);
   }
   if (mEventQueue) {
     wl_display_roundtrip_queue(mDisplay, mEventQueue);