From 931f79a3ba5f1b3989e8fa88949710c4340c30df Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Sat, 25 Feb 2023 22:20:17 +0000 Subject: [PATCH] Bug 1777849 - Avoid calling XSynchronize in error handler unless debugging. r=gfx-reviewers,ahale In many crash reports where we're hitting the libX11 sequence number race inside poll_for_event, we hit this as a result of XSychronize being called inside the X error handler in glXCreateContextAttribs. In general we rely on GLX functions to return error values rather than attempt to catch errors, so polling with these functions might cause unnecessary extra libX11 traffic that makes us more susceptible to crashing if we do call XSynchronize. Upstream libX11 bug reports seem to hint at similar reported problems with XSynchronize used as such, so for now, it seems prudent to disable this unless we're debugging and really need the extra warning information. Differential Revision: https://phabricator.services.mozilla.com/D170996 --- toolkit/xre/nsX11ErrorHandler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/toolkit/xre/nsX11ErrorHandler.cpp b/toolkit/xre/nsX11ErrorHandler.cpp index 3d36e8484c82..77f71db8f9d8 100644 --- a/toolkit/xre/nsX11ErrorHandler.cpp +++ b/toolkit/xre/nsX11ErrorHandler.cpp @@ -51,9 +51,11 @@ static void QueryXExtensions(Display* aDisplay) { extern "C" { int X11Error(Display* display, XErrorEvent* event) { +#ifdef DEBUG // Get an indication of how long ago the request that caused the error was // made. unsigned long age = NextRequest(display) - event->serial; +#endif // Get a string to represent the request that caused the error. nsAutoCString message; @@ -96,6 +98,7 @@ int X11Error(Display* display, XErrorEvent* event) { XGetErrorText(display, event->error_code, buffer, sizeof(buffer)); notes.Append(buffer); +#ifdef DEBUG // For requests where Xlib gets the reply synchronously, |age| will be 1 // and the stack will include the function making the request. For // asynchronous requests, the current stack will often be unrelated to the @@ -118,7 +121,6 @@ int X11Error(Display* display, XErrorEvent* event) { } } -#ifdef DEBUG // The resource id is unlikely to be useful in a crash report without // context of other ids, but add it to the debug console output. notes.AppendLiteral("; id=0x");