From 6f8e6f9a19559c24947b6b22c68b4722865746ff Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 5 Jan 2023 17:31:20 +1100 Subject: [PATCH] [client] x11: catch and print details of X11 errors with a backtrace --- client/displayservers/X11/x11.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index f36db977..a23c1be9 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -242,12 +242,31 @@ out: return; } +static int x11ErrorHandler(Display * display, XErrorEvent * error) +{ + char errorText[1024]; + XGetErrorText(display, error->error_code, errorText, sizeof(errorText)); + + DEBUG_ERROR("X11 Error: %s", errorText); + DEBUG_PRINT_BACKTRACE(); + return 0; +} + +static int x11IOErrorHandler(Display * display) +{ + DEBUG_FATAL("Fatal X11 IO Error"); + return 0; +} + static bool x11Init(const LG_DSInitParams params) { XIDeviceInfo *devinfo; int count; int event, error; + XSetErrorHandler(x11ErrorHandler); + XSetIOErrorHandler(x11IOErrorHandler); + memset(&x11, 0, sizeof(x11)); x11.xValuator = -1; x11.yValuator = -1;