bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Pierre Neidhardt-2

Tested with emacs -Q: opening a .art file
(e.g. https://raw.githubusercontent.com/euhmeuh/rilouw.eu/master/articles/hello.art)
will hang Emacs for about a minute (on a rather powerful computer).  CPU
is about 0% but disk I/O oscillates between 80MB/s-400MB/s (your mileage
may vary).

It seems to be because Emacs tries to open the .art file in image-mode.
The regexp seems to be added by imagemagick-register-types.

Removing .art from auto-mode-alist works.  The following workaround will
remove the complete regexp, that is, all extensions added by
imagemagick-register-types.

  (dolist (pair auto-mode-alist)
    (when (string-match (car pair) ".art")
      (delete pair auto-mode-alist)))





In GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.0)
 of 2018-11-14 built on localhost
Windowing system distributor 'The X.Org Foundation', version 11.0.12003000

Configured using:
 'configure
 CONFIG_SHELL=/gnu/store/q19l04vd2za80mk1845pz7r8cz29qk43-bash-minimal-4.4.23/bin/bash
 SHELL=/gnu/store/q19l04vd2za80mk1845pz7r8cz29qk43-bash-minimal-4.4.23/bin/bash
 --prefix=/gnu/store/vsiqlxhj7lnydhhi85jc1pg0xzhcfdny-emacs-26.1
 --enable-fast-install'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GSETTINGS NOTIFY ACL
GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 THREADS

Important settings:
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: mu4e:view
<#secure method=pgpmime mode=sign>

--
Pierre Neidhardt
https://ambrevar.xyz/



Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Basil L. Contovounesios
Pierre Neidhardt <[hidden email]> writes:

> Removing .art from auto-mode-alist works.  The following workaround will
> remove the complete regexp, that is, all extensions added by
> imagemagick-register-types.
>
>   (dolist (pair auto-mode-alist)
>     (when (string-match (car pair) ".art")
>       (delete pair auto-mode-alist)))

Another way of achieving this would be through customising
imagemagick-types-inhibit or imagemagick-enabled-types, right?

--
Basil



Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Pierre Neidhardt-2

> Another way of achieving this would be through customising
> imagemagick-types-inhibit or imagemagick-enabled-types, right?

Thanks for sharing, I didn't know about these.  Yes, that would be a better
workaround.

That said, there is an issue and image-mode should not try to do what ever it is
doing when loading plain text...  Not sure how we could prevent that.

--
Pierre Neidhardt
https://ambrevar.xyz/

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Eli Zaretskii
In reply to this post by Pierre Neidhardt-2
> From: Pierre Neidhardt <[hidden email]>
> Date: Wed, 06 Feb 2019 13:31:15 +0100
>
> Tested with emacs -Q: opening a .art file
> (e.g. https://raw.githubusercontent.com/euhmeuh/rilouw.eu/master/articles/hello.art)
> will hang Emacs for about a minute (on a rather powerful computer).  CPU
> is about 0% but disk I/O oscillates between 80MB/s-400MB/s (your mileage
> may vary).
>
> It seems to be because Emacs tries to open the .art file in image-mode.
> The regexp seems to be added by imagemagick-register-types.
>
> Removing .art from auto-mode-alist works.

Not sure I understand: are you saying that hello.art uses an extension
of some image files, but is not an image?  If so, why is that a bug --
these things can happen with any file, and removing an extension just
because there's one example to the contrary isn't necessarily a good
idea.

Or did I miss something?

Thanks.



Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Glenn Morris-3
In reply to this post by Pierre Neidhardt-2

This is a duplicate of https://debbugs.gnu.org/22289 .



Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Glenn Morris-3
In reply to this post by Eli Zaretskii

I've never heard of .art image files.

According to
https://en.wikipedia.org/wiki/ART_image_file_format

"ART is a proprietary image file format used mostly by the America
Online (AOL) service"

I doubt many people want to look at such images with Emacs.
Given that .art more often seems to be used for something else that
isn't an image but causes big problems for ImageMagick, it seems like a
good idea to add it to the default value of imagemagick-types-inhibit.



Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Glenn Morris-3
Glenn Morris wrote:

> it seems like a good idea to add it to the default value of
> imagemagick-types-inhibit.

Or rather, remove ART from the default imagemagick-enabled-types.



Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Pierre Neidhardt-2
> Not sure I understand: are you saying that hello.art uses an extension
> of some image files, but is not an image?  If so, why is that a bug --
> these things can happen with any file, and removing an extension just
> because there's one example to the contrary isn't necessarily a good
> idea.
>
> Or did I miss something?

Sorry if this was unclear.

Extensions and actual content don't necessary match the auto-mode-alist mapping.

If the extension does not match Emacs' expectations, it should not freeze it for
a minute and almost halt the computer to a grind.

In other words, Emacs should fail gracefully when image-mode does not make sense
with the actual content of the file.

Does that make sense?

--
Pierre Neidhardt
https://ambrevar.xyz/

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Pierre Neidhardt-2
In reply to this post by Eli Zaretskii

> This is a duplicate of https://debbugs.gnu.org/22289 .

It is indeed, thanks for looking it up!

--
Pierre Neidhardt
https://ambrevar.xyz/

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Eli Zaretskii
In reply to this post by Pierre Neidhardt-2
> From: Pierre Neidhardt <[hidden email]>
> Cc: Eli Zaretskii <[hidden email]>, [hidden email]
> Date: Wed, 06 Feb 2019 21:53:26 +0100
>
> If the extension does not match Emacs' expectations, it should not freeze it for
> a minute and almost halt the computer to a grind.
>
> In other words, Emacs should fail gracefully when image-mode does not make sense
> with the actual content of the file.
>
> Does that make sense?

I does, I just think that your desire is generally unattainable, even
though in the specific case in point perhaps we should simply drop
support for .art extensions.



Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Pierre Neidhardt-2

> I does, I just think that your desire is generally unattainable, even
> though in the specific case in point perhaps we should simply drop
> support for .art extensions.

I think there is a misunderstanding (probably due to my initial post and the
poor title).  The issue, I  believe, is with image-mode: when it is fed random
bytes (e.g. a text buffer) it goes berserk.  This is probably a bug in
image-mode.

--
Pierre Neidhardt
https://ambrevar.xyz/

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Eli Zaretskii
> From: Pierre Neidhardt <[hidden email]>
> Cc: [hidden email], [hidden email]
> Date: Thu, 07 Feb 2019 13:04:58 +0100
>
> I think there is a misunderstanding (probably due to my initial post and the
> poor title).  The issue, I  believe, is with image-mode: when it is fed random
> bytes (e.g. a text buffer) it goes berserk.  This is probably a bug in
> image-mode.

Does image-mode goes berserk, or does ImageMagick do it?  AFAIU, we
just hand the file to the appropriate image library for processing.



Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Pierre Neidhardt-2
Could be.  Any hint on how I could test that more specifically?

--
Pierre Neidhardt
https://ambrevar.xyz/

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Stephen Berman
In reply to this post by Eli Zaretskii
On Thu, 07 Feb 2019 16:44:21 +0200 Eli Zaretskii <[hidden email]> wrote:

>> From: Pierre Neidhardt <[hidden email]>
>> Cc: [hidden email], [hidden email]
>> Date: Thu, 07 Feb 2019 13:04:58 +0100
>>
>> I think there is a misunderstanding (probably due to my initial post and the
>> poor title).  The issue, I  believe, is with image-mode: when it is fed random
>> bytes (e.g. a text buffer) it goes berserk.  This is probably a bug in
>> image-mode.
>
> Does image-mode goes berserk, or does ImageMagick do it?  AFAIU, we
> just hand the file to the appropriate image library for processing.

On Thu, 07 Feb 2019 15:59:14 +0100 Pierre Neidhardt <[hidden email]> wrote:

> Could be.  Any hint on how I could test that more specifically?

Try opening the file from the shell with the 'display' command (and have
another shell ready to kill that process).

Steve Berman



Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Glenn Morris-3
Stephen Berman wrote:

> Try opening the file from the shell with the 'display' command (and have
> another shell ready to kill that process).

This was already investigated in
https://debbugs.gnu.org/22289#8
https://debbugs.gnu.org/22289#20



Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Pierre Neidhardt-2
Thank you for the links, Glenn!

Sounds like removing the .art auto-load would not be so bad after all.
Thoughts?

--
Pierre Neidhardt
https://ambrevar.xyz/

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#34346: 26.1; Big hang when opening text (racket) files with .art extension (image-mode)

Eli Zaretskii
In reply to this post by Pierre Neidhardt-2
> From: Pierre Neidhardt <[hidden email]>
> Cc: [hidden email], [hidden email]
> Date: Thu, 07 Feb 2019 15:59:14 +0100
>
> Could be.  Any hint on how I could test that more specifically?

One possible way is to attach a debugger to Emacs while this
processing goes on, and produce a backtrace to see what code is
working.