unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dhruva Krishnamurthy <dhruvakm@gmail.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: emacs-devel@gnu.org
Subject: Re: Build segfaults when loading image.el
Date: Tue, 24 Dec 2019 07:38:54 -0800	[thread overview]
Message-ID: <CAKOHPAmXFneDCrEznN4VAsGHw5-U6KPZovD0mo3z72Y5vP5uow@mail.gmail.com> (raw)
In-Reply-To: <550d1942-f29c-4801-356d-a8c4b3b77ea4@cs.ucla.edu>

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

On further reading the ImageMagick source, I would that the calls to
'MagickWandGenesis' protect themselves against redundant repeat calls.
Hence, there is no need to protect it using a static variable. The
following patch is a minimal fix.

Link to source:
https://github.com/ImageMagick/ImageMagick/blob/f775a5cf27a95c42bb6d19b50f4869db265fdaa9/MagickWand/magick-wand.c#L1001

-dhruva

commit 23236f26d2f5839f2fdb7022039dcf102dcf3a3b
Author: Dhruva Krishnamurthy <dhruvakm@gmail.com>
Date:   Mon Dec 23 14:49:51 2019 -0800

    Initialize ImageMagick runtime environment before use

diff --git a/src/image.c b/src/image.c
index 70d932f9ed..75c31cad57 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8875,13 +8875,8 @@ imagemagick_load_image (struct frame *f, struct
image *img,
   char hint_buffer[MaxTextExtent];
   char *filename_hint = NULL;

-  /* Initialize the ImageMagick environment.  */
-  static bool imagemagick_initialized;
-  if (!imagemagick_initialized)
-    {
-      imagemagick_initialized = true;
-      MagickWandGenesis ();
-    }
+  /* Initialize the ImageMagick environment if not initialized. */
+  MagickWandGenesis ();

   /* Handle image index for image types who can contain more than one
image.
      Interface :index is same as for GIF.  First we "ping" the image to
see how
@@ -9290,6 +9285,9 @@ DEFUN ("imagemagick-types", Fimagemagick_types,
Simagemagick_types, 0, 0, 0,
   char **imtypes;
   size_t i;

+  /* Initialize the ImageMagick environment if not initialized. */
+  MagickWandGenesis ();
+
   ex = AcquireExceptionInfo ();
   imtypes = GetMagickList ("*", &numf, ex);
   DestroyExceptionInfo (ex);


On Mon, Dec 23, 2019 at 6:51 PM Paul Eggert <eggert@cs.ucla.edu> wrote:

> On 12/23/19 6:09 PM, Dhruva Krishnamurthy wrote:
> > I still feel the original patch calling into IsMagickWandInstantiated()
> was
> > more correct
>
> Not sure I follow, but anyway any change along those lines would be more
> experimental, whereas the emacs-27 branch is for bug-fixing and is
> maintained
> more conservatively.
>
> PS. I didn't notice the "!!IsMagickWandInstantiated();" part of your
> patch; if I
> had, I would have omitted it from the emacs-27 branch and would have said
> why.
>

[-- Attachment #2: Type: text/html, Size: 4603 bytes --]

  reply	other threads:[~2019-12-24 15:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-23 21:59 Build segfaults when loading image.el Dhruva Krishnamurthy
2019-12-23 22:43 ` Dhruva Krishnamurthy
2019-12-24  1:24 ` Paul Eggert
2019-12-24  2:09   ` Dhruva Krishnamurthy
2019-12-24  2:51     ` Paul Eggert
2019-12-24 15:38       ` Dhruva Krishnamurthy [this message]
2019-12-24 13:12   ` VanL
2019-12-24 13:22     ` Lars Ingebrigtsen
2019-12-25  2:03       ` VanL

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=CAKOHPAmXFneDCrEznN4VAsGHw5-U6KPZovD0mo3z72Y5vP5uow@mail.gmail.com \
    --to=dhruvakm@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).