Commit 51d265f2 authored by Robert Mader's avatar Robert Mader
Browse files

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
parent eba28ae2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -324,6 +324,10 @@ 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),
@@ -341,6 +345,10 @@ nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay)
      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()) {