From fe46cbea0f19959d469ca4d1f09be379dc7b1e45 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Tue, 21 Nov 2017 14:45:13 +0100 Subject: [PATCH xserver] =?UTF-8?q?xwayland:=20Give=20up=20=E2=80=9Ccleanl?= =?UTF-8?q?y=E2=80=9C=20on=20Wayland=20socket=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Xwayland is a pretty standard Wayland client, we want to be able to capture core dumps on crashes. Yet using "-core" causes any FatalError() to generate a core dump, meaning that we would get a core file for all Wayland server crashes, which would generate a lot of false positives. Instead of using FatalError() on Wayland socket errors, give up cleanly to avoid dumping core files when "-core" is used. See also: https://bugzilla.gnome.org/show_bug.cgi?id=790502 and: https://bugzilla.gnome.org/show_bug.cgi?id=789086 Reviewed-by: Adam Jackson Signed-off-by: Olivier Fourdan --- hw/xwayland/xwayland.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c index 638022180..c5a3ae7ae 100644 --- a/hw/xwayland/xwayland.c +++ b/hw/xwayland/xwayland.c @@ -73,6 +73,22 @@ ddxBeforeReset(void) } #endif + _X_NORETURN +static void _X_ATTRIBUTE_PRINTF(1, 2) +xwl_give_up(const char *f, ...) +{ + va_list args; + + va_start(args, f); + VErrorFSigSafe(f, args); + va_end(args); + + CloseWellKnownConnections(); + OsCleanup(TRUE); + fflush(stderr); + exit(1); +} + void ddxUseMsg(void) { @@ -719,13 +735,13 @@ xwl_read_events (struct xwl_screen *xwl_screen) ret = wl_display_read_events(xwl_screen->display); if (ret == -1) - FatalError("failed to read Wayland events: %s\n", strerror(errno)); + xwl_give_up("failed to read Wayland events: %s\n", strerror(errno)); xwl_screen->prepare_read = 0; ret = wl_display_dispatch_pending(xwl_screen->display); if (ret == -1) - FatalError("failed to dispatch Wayland events: %s\n", strerror(errno)); + xwl_give_up("failed to dispatch Wayland events: %s\n", strerror(errno)); } static int @@ -752,7 +768,7 @@ xwl_dispatch_events (struct xwl_screen *xwl_screen) wl_display_prepare_read(xwl_screen->display) == -1) { ret = wl_display_dispatch_pending(xwl_screen->display); if (ret == -1) - FatalError("failed to dispatch Wayland events: %s\n", + xwl_give_up("failed to dispatch Wayland events: %s\n", strerror(errno)); } @@ -761,13 +777,13 @@ xwl_dispatch_events (struct xwl_screen *xwl_screen) pollout: ready = xwl_display_pollout(xwl_screen, 5); if (ready == -1 && errno != EINTR) - FatalError("error polling on XWayland fd: %s\n", strerror(errno)); + xwl_give_up("error polling on XWayland fd: %s\n", strerror(errno)); if (ready > 0) ret = wl_display_flush(xwl_screen->display); if (ret == -1 && errno != EAGAIN) - FatalError("failed to write to XWayland fd: %s\n", strerror(errno)); + xwl_give_up("failed to write to XWayland fd: %s\n", strerror(errno)); xwl_screen->wait_flush = (ready == 0 || ready == -1 || ret == -1); } -- 2.14.3