[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#998888: X-device: BadDrawable (invalid Pixmap or Window parameter)



Package: ghostscript-x
Version: 9.54.0~dfsg-5
Severity: normal
Tags: patch

Dear Maintainer,

upstream commit 033ed8bf196b1cddd681a9b32d9398bf6bc02d24 (included in
debian/9.54.0~dfsg-1) introduced a call to XFreePixmap in gdev_x_close.
This might free a pixmap that was created by ghostview as a backing
pixmap and might still be used by ghostview for further drawing.

I'm not entirely sure which files causes the gs process to close the device
early, but with some files it does and gv actions like reloading/zooming
attempt to draw on the already freed pixmap and cause gv to crash with

X Error of failed request:  BadPixmap (invalid Pixmap parameter).

Especially the -watch option of gv is broken if it is used to watch a
postscript file that's in development. Any postscript error will cause the
device to free the backing pixmap and ghostview will crash even if the
error in the file gets fixed. It was possible to do that in the past (the
backing pixmap was reused with a new gs process).

It's possible to reproduce the issue with a small example file like this:

newpath
100 200 moveto
200 250 lineto
100 300 lineto
2 setlinewidth
stroke

Please note that there is no "showpage", which seems to cause the invocation
of gdev_x_close (with showpage, the gs process keeps running). With such a
file gv will crash when trying to zoom / reload etc. (ghostview needs to run
with backing pixmap enabled (-pixmap), the -nopixmap option will of course
work around the bug).

I attached a simple patch that checks if the pixmap is created by ghostview
(xdev->ghostview is set) and only frees it if that's not the case.

Cheers,
Florian


-- System Information:
Debian Release: bookworm/sid
  APT prefers testing
  APT policy: (550, 'testing'), (210, 'unstable'), (1, 'experimental')
Architecture: i386 (x86_64)

Kernel: Linux 4.14.151-64+ (SMP w/96 CPU threads; PREEMPT)
Kernel taint flags: TAINT_DIE
Locale: LANG=C, LC_CTYPE=de_DE (charmap=ISO-8859-1), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages ghostscript-x depends on:
ii  ghostscript  9.54.0~dfsg-5bfw3
ii  libc6        2.32-4bfw1
ii  libx11-6     2:1.7.2-2+b1
ii  libxt6       1:1.2.0-1

ghostscript-x recommends no packages.

ghostscript-x suggests no packages.

-- no debconf information
>From c924286b5844456605eb8a7e449cf66e1e220a76 Mon Sep 17 00:00:00 2001
From: Florian Lindemann <linde@bfw-online.de>
Date: Tue, 9 Nov 2021 14:56:49 +0100
Subject: [PATCH] patch

---
 devices/gdevxini.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/devices/gdevxini.c b/devices/gdevxini.c
index 82032cd6..a2f96240 100644
--- a/devices/gdevxini.c
+++ b/devices/gdevxini.c
@@ -960,7 +960,7 @@ gdev_x_close(gx_device_X *xdev)
         xdev->gc = NULL;
     }
     if (xdev->dpy && xdev->bpixmap != (Pixmap)0) {
-        XFreePixmap(xdev->dpy, xdev->bpixmap);
+        if (!xdev->ghostview) XFreePixmap(xdev->dpy, xdev->bpixmap);
         xdev->bpixmap = (Pixmap)0;
         xdev->dest = (Pixmap)0;
     }
-- 
2.33.0


Reply to: