Blame SOURCES/0001-Fix-XTS-regression-in-XCopyColormapAndFree.patch

c4348b
From a515545065ce6e1924de4bc50aaae7ec9b48cfad Mon Sep 17 00:00:00 2001
c4348b
From: Adam Jackson <ajax@redhat.com>
c4348b
Date: Wed, 11 Dec 2019 11:53:11 -0500
c4348b
Subject: [PATCH libX11] Fix XTS regression in XCopyColormapAndFree
c4348b
MIME-Version: 1.0
c4348b
Content-Type: text/plain; charset=UTF-8
c4348b
Content-Transfer-Encoding: 8bit
c4348b
c4348b
XCopyColormapAndFree/5 threw an assertion:
c4348b
c4348b
    520|4 5 00014017 1 2|Assertion XCopyColormapAndFree-5.(A)
c4348b
    520|4 5 00014017 1 3|When a colourmap argument does not name a valid colourmap,
c4348b
    520|4 5 00014017 1 4|then a BadColor error occurs.
c4348b
    520|4 5 00014017 1 5|METH: Create a bad colourmap by creating and freeing a colourmap.
c4348b
    520|4 5 00014017 1 6|METH: Call test function using bad colourmap as the colourmap argument.
c4348b
    520|4 5 00014017 1 7|METH: Verify that a BadColor error occurs.
c4348b
    520|4 5 00014017 1 8|unexpected signal 6 (SIGABRT) received
c4348b
    220|4 5 2 15:05:53|UNRESOLVED
c4348b
    410|4 5 1 15:05:53|IC End
c4348b
    510|4|system 0: Abandoning testset: caught unexpected signal 11 (SIGSEGV)
c4348b
c4348b
More specifically:
c4348b
c4348b
    lt-XCopyColormapAndFree: xcb_io.c:533: _XAllocID: Assertion `ret != inval_id' failed.
c4348b
c4348b
This bug was introduced (by following my advice, d'oh) in:
c4348b
c4348b
    commit 99a2cf1aa0b58391078d5d3edf0a7dab18c7745d
c4348b
    Author: Tapani Pälli <tapani.palli@intel.com>
c4348b
    Date:   Mon May 13 08:29:49 2019 +0300
c4348b
c4348b
        Protect colormap add/removal with display lock
c4348b
c4348b
In that patch we moved the call to _XcmsCopyCmapRecAndFree inside the
c4348b
display lock. The problem is said routine has side effects, including
c4348b
trying to implicitly create a colormap in some cases. Since we don't run
c4348b
the XID handler until SyncHandle() we would see inconsistent internal
c4348b
xlib state, triggering the above assert.
c4348b
c4348b
Fix this by dropping and re-taking the display lock before calling into
c4348b
XCMS.
c4348b
---
c4348b
 src/CopyCmap.c | 5 +++++
c4348b
 1 file changed, 5 insertions(+)
c4348b
c4348b
diff --git a/src/CopyCmap.c b/src/CopyCmap.c
c4348b
index b4954b01..b37aba73 100644
c4348b
--- a/src/CopyCmap.c
c4348b
+++ b/src/CopyCmap.c
c4348b
@@ -53,6 +53,11 @@ Colormap XCopyColormapAndFree(
c4348b
     mid = req->mid = XAllocID(dpy);
c4348b
     req->srcCmap = src_cmap;
c4348b
 
c4348b
+    /* re-lock the display to keep XID handling in sync */
c4348b
+    UnlockDisplay(dpy);
c4348b
+    SyncHandle();
c4348b
+    LockDisplay(dpy);
c4348b
+
c4348b
 #if XCMS
c4348b
     _XcmsCopyCmapRecAndFree(dpy, src_cmap, mid);
c4348b
 #endif
c4348b
-- 
c4348b
2.23.0
c4348b