Commit 9bd056ab authored by Tom Anderson's avatar Tom Anderson Committed by Chromium LUCI CQ

[XProto] Check that the Xlib event queue is empty on destruction

The event queue is never cleared, so if any events are requested,
they'll leak memory.  This CL adds a check to ensure no events were
ever pending.  It's added as a CHECK(), not a DCHECK(), since we
want to receive crash reports if users with untested GPU drivers
ever hit this.

Change-Id: I2aa2fd9f88a1637deff5e81996de71c1d5956e0f
Bug: 1158170
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2602704
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840705}
parent ff0b78c2
......@@ -36,6 +36,7 @@ generate_library_loader("xlib_loader") {
"XSynchronize",
"XSetErrorHandler",
"XFree",
"XPending",
]
}
......
......@@ -13,6 +13,7 @@ int XFlush(struct _XDisplay*);
int XSynchronize(struct _XDisplay*, int);
int XSetErrorHandler(int (*)(void*, void*));
void XFree(void*);
int XPending(struct _XDisplay*);
}
#endif // UI_GFX_X_XLIB_H_
......@@ -73,8 +73,15 @@ XlibDisplay::XlibDisplay(const std::string& address) {
DISABLE_CFI_ICALL
XlibDisplay::~XlibDisplay() {
if (display_)
GetXlibLoader()->XCloseDisplay(display_);
if (!display_)
return;
auto* loader = GetXlibLoader();
// Events are not processed on |display_|, so if any client asks to receive
// events, they will just queue up and leak memory. This check makes sure
// |display_| never had any pending events before it is closed.
CHECK(!loader->XPending(display_));
loader->XCloseDisplay(display_);
}
DISABLE_CFI_ICALL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment