unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dhruva Krishnamurthy <dhruvakm@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: Build segfaults when loading image.el
Date: Mon, 23 Dec 2019 14:43:55 -0800	[thread overview]
Message-ID: <CAKOHPAmeaiyxzb1cCSAqXC+bC9Ka=4wc-=xBU-iTaAfLxSCr-Q@mail.gmail.com> (raw)
In-Reply-To: <CAKOHPAmqm2dw4R9xeY3wTOgh70KNwn_=jBZ1y1v6jtddeRD3ug@mail.gmail.com>

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

Missed providing other details:

# Build host env
$ uname -a
Darwin C02V341YHTD8 19.2.0 Darwin Kernel Version 19.2.0: Sat Nov  9
03:47:04 PST 2019; root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64 i386
MacBookPro14,3 Darwin

# Configure options
$ configure CC=clang --with-imagemagick

# ImageMagic details
$ MagickWand-config --cflags --ldflags
-Xpreprocessor -fopenmp -DMAGICKCORE_HDRI_ENABLE=1
-DMAGICKCORE_QUANTUM_DEPTH=16 -Xpreprocessor -fopenmp
-DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
-I/usr/local/Cellar/imagemagick/7.0.9-10/include/ImageMagick-7
-L/usr/local/Cellar/imagemagick/7.0.9-10/lib -lMagickWand-7.Q16HDRI
-lMagickCore-7.Q16HDRI


On Mon, Dec 23, 2019 at 1:59 PM Dhruva Krishnamurthy <dhruvakm@gmail.com>
wrote:

> 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: 5912 bytes --]

  reply	other threads:[~2019-12-23 22:43 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 [this message]
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

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='CAKOHPAmeaiyxzb1cCSAqXC+bC9Ka=4wc-=xBU-iTaAfLxSCr-Q@mail.gmail.com' \
    --to=dhruvakm@gmail.com \
    --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).