From 22651ed2217632a34bb9045306fac6ab9a2b3414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 14 Jul 2021 20:51:42 +0200 Subject: [PATCH] shm: reset buffer pool FD when we close it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes an issue where we ended up "double closing" buffer FDs. In many cases (especially on compositors with SSDs) this was pretty rare. And even when it did happen, the FD was normally unused, and thus nothing bad happened. However, by quickly resizing the window while using CSDs, it was fairly easy to trigger this. We sometimes ended up closing the TIOCSWINCH timer FD while thinking it was a buffer FD, but most of the times we just ended up closing _another_ buffer’s pool FD, leading to an immediate disconnect by the compositor. --- shm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/shm.c b/shm.c index 00804400..cad60aae 100644 --- a/shm.c +++ b/shm.c @@ -420,6 +420,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, /* We only need to keep the pool FD open if we’re going to SHM * scroll it */ close(pool_fd); + ret->fd = -1; } return ret;