unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Fabio Leimgruber <fabio.leimgruber@web.de>
Cc: 55654@debbugs.gnu.org
Subject: bug#55654: 28.1.50; HEAP Error with ImageMagick on Windows MSYS2
Date: Thu, 26 May 2022 14:43:17 +0300	[thread overview]
Message-ID: <835ylsplii.fsf@gnu.org> (raw)
In-Reply-To: <j90r14g6215.fsf@web.de> (message from Fabio Leimgruber on Thu, 26 May 2022 12:06:46 +0200)

> From: Fabio Leimgruber <fabio.leimgruber@web.de>
> Date: Thu, 26 May 2022 12:06:46 +0200
> 
> Compiled Emacs with these options:
> 
> --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --with-wide-int --with-jpeg --with-xpm --with-png --with-tiff --with-rsvg --with-xml2 --with-gnutls --with-xft --with-imagemagick --with-modules --with-json --with-native-compilation LDFLAGS=-fstack-protector
> 
> The error is triggered when I do find-file, which uses helm and treemacs in turn loading images via ImageMagick.
> 
> Running Emacs under GDB shows the backtrace below.
> 
> Any hints on debugging this further?
> 
> #+begin_example
> warning: HEAP[emacs.exe]:
> warning: Invalid address specified to RtlValidateHeap( 000001EE1E190000, 000001EE25BC1B80 )
> 
> Thread 1 received signal SIGTRAP, Trace/breakpoint trap.
> 0x00007ff99eaca313 in ntdll!RtlRegisterSecureMemoryCacheCallback () from C:\WINDOWS\SYSTEM32\ntdll.dll
> (gdb) bt
> #0  0x00007ff99eaca313 in ntdll!RtlRegisterSecureMemoryCacheCallback () from C:\WINDOWS\SYSTEM32\ntdll.dll
> #1  0x00007ff99ea8cd24 in ntdll!memset () from C:\WINDOWS\SYSTEM32\ntdll.dll
> #2  0x00007ff99ea2e115 in ntdll!RtlValidateHeap () from C:\WINDOWS\SYSTEM32\ntdll.dll
> #3  0x00007ff92596750f in NotifyShims () from C:\WINDOWS\SYSTEM32\AcLayers.dll
> #4  0x00007ff99e269c9c in msvcrt!free () from C:\WINDOWS\System32\msvcrt.dll
> #5  0x00007ff92575b662 in ?? () from C:\Users\LeimgruberF\opt\msys64\mingw64\bin\libMagickCore-7.Q16HDRI-7.dll

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.





  reply	other threads:[~2022-05-26 11:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26 10:06 bug#55654: 28.1.50; HEAP Error with ImageMagick on Windows MSYS2 Fabio Leimgruber
2022-05-26 11:43 ` Eli Zaretskii [this message]
2022-05-29  9:12   ` Fabio Leimgruber
2022-05-29  9:55     ` Eli Zaretskii
2022-06-10 10:52       ` Fabio Leimgruber

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=835ylsplii.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=55654@debbugs.gnu.org \
    --cc=fabio.leimgruber@web.de \
    /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).