From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#35725: 26.2; Fatal error 11: Segmentation fault; Crash on: (find-file "any.svg") Date: Sat, 18 May 2019 10:12:31 -0700 Organization: UCLA Computer Science Department Message-ID: <7effff52-e9a2-8c4a-1d14-42bf86583b04@cs.ucla.edu> References: <87zhnq567e.wl-pegzmasta@member.fsf.org> <1ac79901-d3a1-3c3f-1590-d3fc753e4bac@cs.ucla.edu> <515160ba-0ae7-4bdb-6fd2-9816f8603b83@cs.ucla.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------4B2C2E5BE32A349C61A7CDDD" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="186056"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 Cc: Michael Pagan , 35725@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 18 19:14:19 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hS2uX-000mDA-Qd for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 May 2019 19:14:18 +0200 Original-Received: from localhost ([127.0.0.1]:36533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hS2uW-0000R4-LQ for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 May 2019 13:14:16 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:46234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hS2uN-0000NA-6h for bug-gnu-emacs@gnu.org; Sat, 18 May 2019 13:14:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hS2tK-0002JE-Io for bug-gnu-emacs@gnu.org; Sat, 18 May 2019 13:13:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47581) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hS2tK-0002J5-F7 for bug-gnu-emacs@gnu.org; Sat, 18 May 2019 13:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hS2tK-0007XE-57 for bug-gnu-emacs@gnu.org; Sat, 18 May 2019 13:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 May 2019 17:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35725 X-GNU-PR-Package: emacs Original-Received: via spool by 35725-submit@debbugs.gnu.org id=B35725.155819956528942 (code B ref 35725); Sat, 18 May 2019 17:13:02 +0000 Original-Received: (at 35725) by debbugs.gnu.org; 18 May 2019 17:12:45 +0000 Original-Received: from localhost ([127.0.0.1]:32892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hS2t3-0007Wk-Ax for submit@debbugs.gnu.org; Sat, 18 May 2019 13:12:45 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:53856) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hS2t0-0007WW-Nw for 35725@debbugs.gnu.org; Sat, 18 May 2019 13:12:43 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E8436161A3A; Sat, 18 May 2019 10:12:36 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id riUYG310xeQ6; Sat, 18 May 2019 10:12:36 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id EA6B0161A42; Sat, 18 May 2019 10:12:35 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Uth03qoSEpdS; Sat, 18 May 2019 10:12:35 -0700 (PDT) Original-Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 449B8160F18; Sat, 18 May 2019 10:12:35 -0700 (PDT) In-Reply-To: Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:159500 Archived-At: This is a multi-part message in MIME format. --------------4B2C2E5BE32A349C61A7CDDD Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Glenn Morris wrote: > Hey, thanks for putting my name in a commit that will make people angry. :) You're welcome. But really, they should direct any ire at me. > Putting the priority of libmagick below libpng etc is probably less > contentious, but of course more work. Could you explain what you mean by that? Emacs should already prefer more-specialized code (if available) to libmagick. I just now checked with splash.svg, and found that Emacs used libmagick instead of librsvg when both were available. I tracked this down to a bug in image.el, which I fixed by installing the attached patch into master. Is this the problem you were thinking of, or was it something else? --------------4B2C2E5BE32A349C61A7CDDD Content-Type: text/x-patch; name="0001-For-SVG-8192-is-the-new-256.patch" Content-Disposition: attachment; filename="0001-For-SVG-8192-is-the-new-256.patch" Content-Transfer-Encoding: quoted-printable >From db9af103944959be640a53fcf0f0b696f25d553f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 18 May 2019 10:00:26 -0700 Subject: [PATCH] For SVG, 8192 is the new 256 MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Prefer librsvg for display of splash.svg When both librsvg and Imagemagick are available, Emacs should prefer librsvg to render SVG images. However, Emacs was using Imagemagick to render its own splash.svg file because image-type-from-file-header returned nil for that file. * lisp/image.el (image-type-from-buffer) (image-type-from-file-header): Look at the first 8192 bytes of the image, not just the first 256. For Emacs=E2=80=99s own splash.svg file, image-type-header-regexps needs to look at 939 bytes. 8192 bytes is a reasonable number nowadays given typical file system design. * test/lisp/image-tests.el (image-tests--emacs-images-directory): New contant. (image-type-from-file-header-test): New test. --- lisp/image.el | 4 ++-- test/lisp/image-tests.el | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lisp/image.el b/lisp/image.el index ba87d7f785..db11302086 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -315,7 +315,7 @@ image-type-from-buffer (buffer-substring (point-min) (min (point-max) - (+ (point-min) 256)))))) + (+ (point-min) 8192)))))) (setq image-type (cdr image-type)))) (setq type image-type types nil) @@ -339,7 +339,7 @@ image-type-from-file-header (file-readable-p file) (with-temp-buffer (set-buffer-multibyte nil) - (insert-file-contents-literally file nil 0 256) + (insert-file-contents-literally file nil 0 8192) (image-type-from-buffer)))) =20 =20 diff --git a/test/lisp/image-tests.el b/test/lisp/image-tests.el index 89b926e629..621646e575 100644 --- a/test/lisp/image-tests.el +++ b/test/lisp/image-tests.el @@ -22,6 +22,10 @@ (require 'ert) (require 'image) =20 +(defconst image-tests--emacs-images-directory + (expand-file-name "../etc/images" (getenv "EMACS_TEST_DIRECTORY")) + "Directory containing Emacs images.") + (ert-deftest image--set-property () "Test `image--set-property' behavior." (let ((image (list 'image))) @@ -42,4 +46,11 @@ (setf (image-property image :width) nil) (should (equal image '(image))))) =20 +(ert-deftest image-type-from-file-header-test () + "Test image-type-from-file-header." + (should (eq 'svg + (image-type-from-file-header + (expand-file-name "splash.svg" + image-tests--emacs-images-directory))))) + ;;; image-tests.el ends here --=20 2.17.1 --------------4B2C2E5BE32A349C61A7CDDD--