From 739fce4c12c7aa39112353d80c8a3bf25bdd5274 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 7 Jun 2024 09:07:39 +0200 Subject: [PATCH 2/3] Revert "Protect colormap add/removal with display lock" That commit 99a2cf1aa was moving the calls to the _Xcms*CmapRec*() family of functions within a display lock to make the XCMS colormap functions thread safe. Unfortunately, that causes a deadlock in XCopyColormapAndFree(), because _XcmsCopyCmapRecAndFree() calls CmapRecForColormap() which calls XGetVisualInfo() which also tries to acquire the display lock. So, instead of moving the entire functions within the display lock, let's try to make the functions themselves thread safe in the following commit, and revert this change which causes a deadlock. This reverts commit 99a2cf1aa0b58391078d5d3edf0a7dab18c7745d. Fixes: https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues/215 See-also: https://gitlab.freedesktop.org/xorg/lib/libx11/-/issues/94 Reviewed-by: Adam Jackson Part-of: --- src/CopyCmap.c | 6 +++--- src/CrCmap.c | 6 +++--- src/FreeCmap.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/CopyCmap.c b/src/CopyCmap.c index b4954b01..5444550c 100644 --- a/src/CopyCmap.c +++ b/src/CopyCmap.c @@ -53,12 +53,12 @@ Colormap XCopyColormapAndFree( mid = req->mid = XAllocID(dpy); req->srcCmap = src_cmap; + UnlockDisplay(dpy); + SyncHandle(); + #if XCMS _XcmsCopyCmapRecAndFree(dpy, src_cmap, mid); #endif - UnlockDisplay(dpy); - SyncHandle(); - return(mid); } diff --git a/src/CrCmap.c b/src/CrCmap.c index 1b18a15b..9904c7dd 100644 --- a/src/CrCmap.c +++ b/src/CrCmap.c @@ -48,12 +48,12 @@ Colormap XCreateColormap( if (visual == CopyFromParent) req->visual = CopyFromParent; else req->visual = visual->visualid; + UnlockDisplay(dpy); + SyncHandle(); + #ifdef XCMS _XcmsAddCmapRec(dpy, mid, w, visual); #endif - UnlockDisplay(dpy); - SyncHandle(); - return(mid); } diff --git a/src/FreeCmap.c b/src/FreeCmap.c index 68496dd8..e2b76fa6 100644 --- a/src/FreeCmap.c +++ b/src/FreeCmap.c @@ -41,12 +41,12 @@ XFreeColormap( LockDisplay(dpy); GetResReq(FreeColormap, cmap, req); + UnlockDisplay(dpy); + SyncHandle(); + #ifdef XCMS _XcmsDeleteCmapRec(dpy, cmap); #endif - UnlockDisplay(dpy); - SyncHandle(); - return 1; } -- 2.45.2