From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#55654: 28.1.50; HEAP Error with ImageMagick on Windows MSYS2 Date: Thu, 26 May 2022 14:43:17 +0300 Message-ID: <835ylsplii.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25044"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 55654@debbugs.gnu.org To: Fabio Leimgruber Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 26 14:18:59 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nuCS6-00069k-PH for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 May 2022 14:18:54 +0200 Original-Received: from localhost ([::1]:60556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nuCS5-0000Mj-4v for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 May 2022 08:18:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuBuO-00015L-3z for bug-gnu-emacs@gnu.org; Thu, 26 May 2022 07:44:08 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35014) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nuBuM-00024E-4T for bug-gnu-emacs@gnu.org; Thu, 26 May 2022 07:44:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nuBuM-0003M5-1W for bug-gnu-emacs@gnu.org; Thu, 26 May 2022 07:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 May 2022 11:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55654 X-GNU-PR-Package: emacs Original-Received: via spool by 55654-submit@debbugs.gnu.org id=B55654.165356541812858 (code B ref 55654); Thu, 26 May 2022 11:44:01 +0000 Original-Received: (at 55654) by debbugs.gnu.org; 26 May 2022 11:43:38 +0000 Original-Received: from localhost ([127.0.0.1]:57144 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuBtr-0003LE-Nm for submit@debbugs.gnu.org; Thu, 26 May 2022 07:43:38 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:57292) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuBtq-0003L1-6q for 55654@debbugs.gnu.org; Thu, 26 May 2022 07:43:30 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:60040) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuBtk-00021n-Qb; Thu, 26 May 2022 07:43:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=/Vn29AMLApXuKHQ2czZqVbVA3Sg1QySa/ImkJD+W6fs=; b=aeSrkSYRTG/L 9zbfYdnFG40XBEwhMzdikrSmQB3qgFAkEN/I1402kiSANGA8s3SfDDUAwfCjhZGHO2XyB0u49Lbt3 fDw1x6XB/TS77YGMwgeHNxyM9OTrAk+wF8Jtq6eImZlV+xjWU3ahpiocMUmv+z13/1pLYig+hbCmp kFsWhQjTdnmhZyRLSOlA0/lgHrkXnmEdvhY8PhsXTOtEohXhl/gCOzLR8QuE5oG07EJ65wZa6V1Mg o9oj294+Dj6KhnM6TI/kPaDViZnWbsDVH9rQPf0YahMUWRoad9p0xmtu3gi372ygehY95btWtqOOY qOSWfCV4y//WY3q+m5tMKg==; Original-Received: from [87.69.77.57] (port=3729 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuBtk-00027y-AW; Thu, 26 May 2022 07:43:24 -0400 In-Reply-To: (message from Fabio Leimgruber on Thu, 26 May 2022 12:06:46 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:233104 Archived-At: > From: Fabio Leimgruber > 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.