all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Build segfaults when loading image.el
@ 2019-12-23 21:59 Dhruva Krishnamurthy
  2019-12-23 22:43 ` Dhruva Krishnamurthy
  2019-12-24  1:24 ` Paul Eggert
  0 siblings, 2 replies; 9+ messages in thread
From: Dhruva Krishnamurthy @ 2019-12-23 21:59 UTC (permalink / raw)
  To: emacs-devel

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

Loading image.el segfaults when ImageMagick is enabled on MacOS (do not
have access to other platforms) since image magic environment is not
initialized yet. The following patch on HEAD fixes the crash by
initializing it before use.

-dhruva

diff --git a/src/image.c b/src/image.c
index 70d932f9ed..50d90ccb55 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8603,6 +8603,20 @@ #define DrawRectangle DrawRectangleGif
     MagickPixelPacket *);
 #endif

+/* Initialize the ImageMagick environment if not initialized.  */
+
+static void
+imagemagick_initialize(void)
+{
+  /* Initialize the ImageMagick environment.  */
+  static bool imagemagick_initialized;
+  if (!imagemagick_initialized)
+    {
+      MagickWandGenesis();
+      imagemagick_initialized = !!IsMagickWandInstantiated();
+    }
+}
+
 /* Log ImageMagick error message.
    Useful when an ImageMagick function returns the status `MagickFalse'.
 */

@@ -8876,12 +8890,7 @@ imagemagick_load_image (struct frame *f, struct
image *img,
   char *filename_hint = NULL;

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

   /* 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 +9299,9 @@ DEFUN ("imagemagick-types", Fimagemagick_types,
Simagemagick_types, 0, 0, 0,
   char **imtypes;
   size_t i;

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

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-12-25  2:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2019-12-24 13:12   ` VanL
2019-12-24 13:22     ` Lars Ingebrigtsen
2019-12-25  2:03       ` VanL

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.