all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Glenn Morris <rgm@gnu.org>
Cc: Michael Pagan <pegzmasta@member.fsf.org>, 35725@debbugs.gnu.org
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	[thread overview]
Message-ID: <7effff52-e9a2-8c4a-1d14-42bf86583b04@cs.ucla.edu> (raw)
In-Reply-To: <d236lg7dlw.fsf@fencepost.gnu.org>

[-- Attachment #1: Type: text/plain, Size: 685 bytes --]

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?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-For-SVG-8192-is-the-new-256.patch --]
[-- Type: text/x-patch; name="0001-For-SVG-8192-is-the-new-256.patch", Size: 2744 bytes --]

From db9af103944959be640a53fcf0f0b696f25d553f Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
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=UTF-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’s 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))))
 
 
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)
 
+(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)))))
 
+(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
-- 
2.17.1


  reply	other threads:[~2019-05-18 17:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-13 22:40 bug#35725: 26.2; Fatal error 11: Segmentation fault; Crash on: (find-file "any.svg") Michael Pagan
2019-05-14  1:04 ` Paul Eggert
2019-05-14  1:21   ` Glenn Morris
2019-05-14  3:59     ` Michael Pagan
2019-05-14  7:58       ` Lars Ingebrigtsen
2019-05-14  8:00         ` Lars Ingebrigtsen
2019-05-14 16:04         ` Eli Zaretskii
2019-05-14 16:16           ` Paul Eggert
2019-05-15  0:49             ` Lars Ingebrigtsen
2019-05-15 18:45               ` Alan Third
2019-05-16  3:47                 ` Lars Ingebrigtsen
2019-05-14  6:08     ` Paul Eggert
2019-05-15  0:42       ` Glenn Morris
2019-05-18 17:12         ` Paul Eggert [this message]
2019-05-15  4:07       ` Michael Pagan
2019-05-15  4:22         ` Lars Ingebrigtsen
2019-05-14  1:16 ` Noam Postavsky
2019-05-14 15:25   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7effff52-e9a2-8c4a-1d14-42bf86583b04@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=35725@debbugs.gnu.org \
    --cc=pegzmasta@member.fsf.org \
    --cc=rgm@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.