Subject: bug#55654: 28.1.50; HEAP Error with ImageMagick on Windows MSYS2

From: Fabio Leimgruber <[email-masked]>
Date: Sun, 29 May 2022 11:12:20 +0200

Eli Zaretskii <[email-masked]> writes:

> I think this happens because ImageMagick tries to free memory that
> Emacs allocated.  Emacs on MS-Windows uses its own implementation of
> malloc and free, so a scenario where Emacs allocates and some library
> frees, or vice versa, will never work.
>
> Does ImageMagick has a facility whereby an application can tell it
> what functions to use for allocation and deallocation of memory?  If
> so, we can use those facilities to force ImageMagick to use our
> allocation functions.
>
> If the above doesn't help, I think the way to debug this is to install
> ImageMagick sources and debug info, or build it with debug information
> on your machine, and see what memory is being free'd here, and where
> was it allocated.

Thanks for your analysis and the suggestions.

I just recompiled after upgrading MSYS2 ImageMagick to 7.1.0.35 and the error is gone.

Your comment about malloc and free on MS-Windows got me thinking on how ImageMagick has been working on this machine with Emacs 27.2.50 in the first place.  I was then searching for supported ImageMagick versions, but it seems that starting with Emacs 27 ImageMagick is disabled by default.  Maybe a note on ImageMagick compat for Emacs 28 on MS-Windows MSYS2 could be added to the docs, as long as the option --with-imagemagick is still available?

In any case, please consider this solved from my side.