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
This commit is contained in:
Lee Salzman 2023-02-25 22:20:17 +00:00
Родитель e8346384e4
Коммит 931f79a3ba
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -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");