From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Dhruva Krishnamurthy Newsgroups: gmane.emacs.devel Subject: Build segfaults when loading image.el Date: Mon, 23 Dec 2019 13:59:35 -0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000c278ce059a662655" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="22913"; mail-complaints-to="usenet@blaine.gmane.org" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 23 23:00:22 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ijVkT-0005mN-Pi for ged-emacs-devel@m.gmane.org; Mon, 23 Dec 2019 23:00:21 +0100 Original-Received: from localhost ([::1]:33586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ijVkS-0001oq-08 for ged-emacs-devel@m.gmane.org; Mon, 23 Dec 2019 17:00:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50305) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ijVkM-0001ok-5S for emacs-devel@gnu.org; Mon, 23 Dec 2019 17:00:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ijVkK-0001ME-Ki for emacs-devel@gnu.org; Mon, 23 Dec 2019 17:00:14 -0500 Original-Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]:46740) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ijVkK-0001Lc-Fa for emacs-devel@gnu.org; Mon, 23 Dec 2019 17:00:12 -0500 Original-Received: by mail-ot1-x32d.google.com with SMTP id k8so6597589otl.13 for ; Mon, 23 Dec 2019 14:00:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=Gl9sY5NB/COEbwn+GhplUWJ+iTQb4jRLPldDKwvkoac=; b=eS82KicNdUI/6agWk1jlQ9ClKS8K5Ag5KjE6GjYYplLYAaUsrfTOBLA4rO7v7zns3K hy29PvRoFa5pL9YQ42TK8XQjvk7ZfeGUOd6Cb9Nl4PROlFwfC9tlO3f45KWhR2uRmqTs mgSk/3yYOTn9uzd75gpk1sM3Tlx+R6VNaLjRv2sr/GkzsZAXCUkNws8elvi2DDpWcbmj eude4sRvtYjeiIC8akBRb92kCe8YT2CljLroWx+AScyy94qEzQvnfoaKe/72GBp8Uuy7 zDZl4PKRdPDy99S+W13NUQo3S3eo+J+YN2wNdSMEY+fdIVoVgEepbVCbaH6rPR4rx1M2 A7Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Gl9sY5NB/COEbwn+GhplUWJ+iTQb4jRLPldDKwvkoac=; b=EWPjt5HuL61yV0O0/DbAFL7yY0Ps6D4+xnc0kmKP7GRFIEQngB6OV056oQP4CbcNRD X6xcwnhcWVfnHBdZcOviU2KQ/7Gb49IGIhRx7PtwydQzqln9HHeSuE5PaOg7kgQNp/8y YOguZ1Ja8XOdXtfJv0iXwGQnlZ3flP2URnoRdXm81yTn3l10Ma/R99+wRQUB1yKTQADK PazxPieZm5okJA8V18kKFo3uB7fbp0IyPIIWnoPp4A6SYNIn+nlMELZW4LSbenCTgojz EWtYeLEKENFO+rZYlmLAxMLhe6p4b5TeIdYCBL6tSe+92EfMedigd5/8H3fg3XUwBavp lzjQ== X-Gm-Message-State: APjAAAVYvm4CeImyMwijcSkoAIsUqKYb2P4bZDe4CHxKfIxINUpSNHye CaBG/VTxTNdGht99vlrLj/Ek2kEJ62i01vQjdm2SouW+FjI= X-Google-Smtp-Source: APXvYqwOoxNzO4YnKHkVzuld/2GYRM7y6tHZvPobcIm0w2pJY+eBqBKUUZKbVIenmlsSeN/hurA3r+DMsESxFl1Fvxg= X-Received: by 2002:a9d:51ca:: with SMTP id d10mr33843478oth.76.1577138411172; Mon, 23 Dec 2019 14:00:11 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::32d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:243594 Archived-At: --000000000000c278ce059a662655 Content-Type: text/plain; charset="UTF-8" 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); --000000000000c278ce059a662655 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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
=C2=A0 =C2=A0 =C2=A0Mag= ickPixelPacket *);
=C2=A0#endif
=C2=A0
+/* Initi= alize the ImageMagick environment if not initialized. =C2=A0*/
+
+static void
+imagemagick_initialize(void)
+{
+ =C2=A0/* Initiali= ze the ImageMagick environment. =C2=A0*/
= + =C2=A0static bool imagemagick_initialized;
+ =C2=A0if (!imagemagick_initialized)
+ =C2=A0 =C2=A0{
+ =C2=A0 =C2=A0 =C2=A0M= agickWandGenesis();
+ =C2=A0 =C2=A0 =C2= =A0imagemagick_initialized =3D !!IsMagickWandInstantiated();
+ =C2=A0 =C2=A0}
+}
+
=C2=A0= /* Log ImageMagick error message.
=C2=A0 = =C2=A0 Useful when an ImageMagick function returns the status `MagickFalse&= #39;. =C2=A0*/
=C2=A0
@@ -8876,12 +8890,7 @@ imagemagick_load_image (struct frame = *f, struct image *img,
=C2=A0 =C2=A0char = *filename_hint =3D NULL;
=C2=A0
=C2=A0 =C2=A0/* Initialize the ImageMagick environ= ment. =C2=A0*/
- =C2=A0static bool imagem= agick_initialized;
- =C2=A0if (!imagemagi= ck_initialized)
- =C2=A0 =C2=A0{
- =C2=A0 =C2=A0 =C2=A0imagemagick_initialized =3D= true;
- =C2=A0 =C2=A0 =C2=A0MagickWandGe= nesis ();
- =C2=A0 =C2=A0}
+ =C2=A0imagemagick_initialize();
=C2=A0
=C2=A0 =C2=A0/* Handl= e image index for image types who can contain more than one image.
=C2=A0 =C2=A0 =C2=A0 Interface :index is same as = for GIF.=C2=A0 First we "ping" the image to see how
@@ -9290,6 +9299,9 @@ DEFUN ("imagemagick-types&q= uot;, Fimagemagick_types, Simagemagick_types, 0, 0, 0,
=C2=A0 =C2=A0char **imtypes;
=C2=A0 =C2=A0size_t i;
=C2=A0
+ =C2=A0/* Initialize the ImageMagick environment.= =C2=A0*/
+ =C2=A0imagemagick_initialize(= );
+
= =C2=A0 =C2=A0ex =3D AcquireExceptionInfo ();
=C2=A0 =C2=A0imtypes =3D GetMagickList ("*", &numf, ex);<= /div>
=C2=A0 =C2=A0DestroyExceptionInfo (ex);


--000000000000c278ce059a662655--