From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#44930: I can reproduce it Date: Sat, 5 Dec 2020 19:44:13 +0000 Message-ID: References: <83pn3timo4.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="9n5hNDhyW2/qpxPV" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15648"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 44930@debbugs.gnu.org To: Francesco =?UTF-8?Q?Potort=C3=AC?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 05 20:45:24 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kldUi-0003w1-99 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 05 Dec 2020 20:45:24 +0100 Original-Received: from localhost ([::1]:43746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kldUh-0001f4-B4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 05 Dec 2020 14:45:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kldUM-0001ee-CD for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2020 14:45:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kldUM-0002h7-12 for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2020 14:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kldUL-0002cn-UY for bug-gnu-emacs@gnu.org; Sat, 05 Dec 2020 14:45:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 05 Dec 2020 19:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44930 X-GNU-PR-Package: emacs Original-Received: via spool by 44930-submit@debbugs.gnu.org id=B44930.160719747210037 (code B ref 44930); Sat, 05 Dec 2020 19:45:01 +0000 Original-Received: (at 44930) by debbugs.gnu.org; 5 Dec 2020 19:44:32 +0000 Original-Received: from localhost ([127.0.0.1]:48262 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kldTr-0002bn-Uz for submit@debbugs.gnu.org; Sat, 05 Dec 2020 14:44:32 -0500 Original-Received: from outbound.soverin.net ([116.202.65.218]:48405) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kldTq-0002bV-2S for 44930@debbugs.gnu.org; Sat, 05 Dec 2020 14:44:31 -0500 Original-Received: from smtp.soverin.net (unknown [10.10.3.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id D67FF60164; Sat, 5 Dec 2020 19:44:23 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [159.69.232.138]) by soverin.net Original-Received: by breton.holly.idiocy.org (Postfix, from userid 501) id 1EC4B20285F098; Sat, 5 Dec 2020 19:44:13 +0000 (GMT) Mail-Followup-To: Alan Third , Francesco =?UTF-8?Q?Potort=C3=AC?= , Francesco =?UTF-8?Q?Potort=C3=AC?= , 44930@debbugs.gnu.org Content-Disposition: inline In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:195047 Archived-At: --9n5hNDhyW2/qpxPV Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sat, Dec 05, 2020 at 05:08:15PM +0100, Francesco Potort́ wrote: > >>> In this moment I have a *w3m* buffer on a live Emacs. If I switch to it > >>> on a text frame, everything is well. If I switch to it on an X display, > >>> the frame dies (but Emacs survives). The error is > >>> > >>> X protocol error: BadMatch (invalid parameter attributes) on protocol request 73 > > I managed to find the time to compile emacs with symbols. > > The previous instance of Emacs crashed, so apparently there is a serious > problem somewhere. > > On the plus side, now apparently every instance of a *w3m* buffer > exhibits the problem, which is now easy to reproduce for me. > > The error is: > redisplay: X protocol error: BadMatch (invalid parameter attributes) on protocol request 73 > which points to an XGetImage call where the pixmap or window to be > returned does not satisfy certain geometric criteria, according to > https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#requests:GetImage > > Setting debug-on-error to t tells me that this happens inside > redisplay_internal(). > > I evaluated (x-synchronize t) and then switched to the *w3b* buffer. > > Here is the backtrace. If you help me I can try and continue debugging. > #5 0x00007fc6655e033a in XGetImage () at /usr/lib/x86_64-linux-gnu/libX11.so.6 > #6 0x00005596a19c3788 in image_get_x_image (f=, img=img@entry=0x5596a57dccd0, mask_p=mask_p@entry=false) at ./debian/build-src/src/image.c:2934 > #7 0x00005596a19c938e in image_background (img=0x5596a57dccd0, f=, pimg=pimg@entry=0x0) at ./debian/build-src/src/image.c:1376 Hmm, my suspicion here is that we're calling XGetImage with dimensions that don't match the pixmap since we no longer store the dimensions of the original image. It hadn't occurred to me that we'd ever pull the image BACK from the X server. Can you try with the attached patch, please? -- Alan Third --9n5hNDhyW2/qpxPV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-crash-when-using-XRender-and-restoring-image-fro.patch" >From b2457ae612bd53c3d08cec7ddba703f400a78a2d Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sat, 5 Dec 2020 19:40:08 +0000 Subject: [PATCH] Fix crash when using XRender and restoring image from X (bug#44930) * src/dispextern.h (struct image): Add original dimension elements. * src/image.c (image_set_transform): Store the original dimensions. (image_get_x_image): If we're using transforms use the original dimensions with XGetImage. --- src/dispextern.h | 4 ++++ src/image.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/dispextern.h b/src/dispextern.h index da51772b37..c76822ff39 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3040,6 +3040,10 @@ reset_mouse_highlight (Mouse_HLInfo *hlinfo) # if !defined USE_CAIRO && defined HAVE_XRENDER /* Picture versions of pixmap and mask for compositing. */ Picture picture, mask_picture; + + /* We need to store the original image dimensions in case we have to + call XGetImage. */ + int original_width, original_height; # endif #endif /* HAVE_X_WINDOWS */ #ifdef HAVE_NTGUI diff --git a/src/image.c b/src/image.c index 5eb4132295..9494f9ddc6 100644 --- a/src/image.c +++ b/src/image.c @@ -2131,6 +2131,10 @@ image_set_transform (struct frame *f, struct image *img) # if !defined USE_CAIRO && defined HAVE_XRENDER if (!img->picture) return; + + /* Store the original dimensions as we'll overwrite them later. */ + img->original_width = img->width; + img->original_height = img->height; # endif /* Determine size. */ @@ -2990,6 +2994,11 @@ image_get_x_image (struct frame *f, struct image *img, bool mask_p) if (ximg_in_img) return ximg_in_img; +#ifdef HAVE_XRENDER + else if (img->picture) + return XGetImage (FRAME_X_DISPLAY (f), !mask_p ? img->pixmap : img->mask, + 0, 0, img->original_width, img->original_height, ~0, ZPixmap); +#endif else return XGetImage (FRAME_X_DISPLAY (f), !mask_p ? img->pixmap : img->mask, 0, 0, img->width, img->height, ~0, ZPixmap); -- 2.29.2 --9n5hNDhyW2/qpxPV--