Subject: bug#31771: 26.1; Writing image file with emacs hangs entire system

From: Adam <[email-masked]>
Date: Sat, 9 Jun 2018 18:09:50 -0400

On 06/09/2018 03:47 PM, Noam Postavsky wrote:
> tags 31771 + unreproducible
> quit
> 
> Adam <[email-masked]> writes:
> 
>> After following these commands, your emacs should freeze, and then your
>> entire system should hang a few seconds later.
> 
> I couldn't reproduce this.  No hang, and if I look closely, I can see
> the one black pixel rendered correctly in the top left corner.
> 
> Is your whole system completely frozen, or is it perhaps just using so
> much RAM that it goes into swap and starts thrashing and becomes very
> slow?  If the former, I guess it's some kind of graphics driver thing,
> though it seems a bit funny that an image as simple as a single black
> pixel could wreck it.

I don't think it's RAM-related; I'm seeing ~500MB used of 16GB whenever
the system freezes.

It's actually quite similar to a graphics driver hang, now that you
mention it. The system is unresponsive to input and my cursor freezes,
but audio keeps playing. Emacs also doesn't successfully write the
decoded file to my disk.

I can reproduce the issue in a debug build of 26.1, but the freeze also
truncates my gdb log so I'm having a hard time nailing down exactly
where it occurs (too many lisp interpreter frames :( ). I've also found
that the issue only occurs iff the imagemagick feature is enabled, and
can simply be reproduced with C-x C-f (the decoded black pixel image).

If it's any help, the system freezes before the minibuffer is cleared
and the new image is rendered (The find/write file prompt is still up
and the current buffer isn't changed)

>> My hunch: this is caused by emacs trying to render the image after it's
>> saved. Unfortunately, this causes emacs and my system to hang, so I
>> can't provide any core dumps. I'm using linux 4.16.13, mesa 18.1.1,
>> libpng 1.6.34, and imagemagick 7.0.7.38
> 
>> Configured features:
>> XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
>> ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS
>> GTK3 X11 MODULES THREADS LIBSYSTEMD LCMS2
> 
> Do you really have imagemagick 7?  Or do maybe also have imagemagic 6?
> As far as I know, the patch for Emacs to use v7 is not merged yet:
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25967#41

Ah, my apologies. Here's libmagick6:

$ pacman -Qs libmagick
libmagick6 6.9.9.50-1
libmagick 7.0.7.38-1