BestImageViewer / geeqie

claiming to be the best image viewer / photo collection browser
http://www.geeqie.org/
GNU General Public License v2.0
479 stars 79 forks source link

AVIF causes crash #1247

Open Efenstor opened 9 months ago

Efenstor commented 9 months ago

Setup (please complete the following information):

Describe the bug Displaying this AVIF file causes immediate crash: image-14-02-24-12-17.zip

To reproduce Steps to reproduce the behavior: Try to display the attached file (image-14-02-24-12-17.avif)

Additional information Here are the messages in the console:

Geeqie fatal error
Signal: Invalid memory reference
Code: Address not mapped
Address: 0x00007f2c179ec003
geeqie(_Z14sig_handler_cbiP9siginfo_tPv+0x219)[0x55b128f27e69]
/lib/x86_64-linux-gnu/libc.so.6(+0x3c050)[0x7f2c6d420050]
/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0(+0x17a60)[0x7f2c6ec5ca60]
/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0(+0x16ffe)[0x7f2c6ec5bffe]
/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0(+0x18bd8)[0x7f2c6ec5dbd8]
/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0(gdk_pixbuf_composite_color+0x2c5)[0x7f2c6ec58385]
geeqie(+0x12f945)[0x55b128f54945]
geeqie(+0x1329d9)[0x55b128f579d9]
geeqie(+0x133929)[0x55b128f58929]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x16f)[0x7f2c6e92467f]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x54a38)[0x7f2c6e924a38]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_loop_run+0x6f)[0x7f2c6e924cef]
/lib/x86_64-linux-gnu/libgtk-3.so.0(gtk_main+0x75)[0x7f2c6f008495]
geeqie(main+0x7d1)[0x55b128eb7d81]
/lib/x86_64-linux-gnu/libc.so.6(+0x2724a)[0x7f2c6d40b24a]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85)[0x7f2c6d40b305]
geeqie(_start+0x21)[0x55b128eb9381]

I have compiled geeqie from the sources and tried the latest libheif (1.17.6) but nothing seems to help. I am sure the reason is incorrect processing of the alpha channel, because if I remove alpha the image is displayed normally (that version is also included in the zip).

caclark commented 9 months ago

I do not see this problem. I have libheif 1.16.2 installed.

Please compile with the option meson setup -Ddevel=enabled build More extensive debug output should be produced.

The downside is that extra libraries will need to be installed - I think libdw1 libdwarf1 libunwind8

If you do not wish to install these libraries, no problem - I will try to set up a system that is a clone of your installation.

Efenstor commented 9 months ago

I'll try it.

It seems that basically any AVIF image with alpha channel is either displayed improperly or causes crash. If I just export any image to AVIF from GIMP (it adds alpha to any loaded image by default) I see this:

Screenshot at 2024-02-16 00-35-58 Screenshot at 2024-02-16 00-36-26

And it has nothing to to with HiDPI: I tried switching to standard DPI with MATE Tweak and it's all the same.

Efenstor commented 9 months ago

Ok, here is what I've got with the crash image:

Stack trace (most recent call last):
#14   Object "/usr/local/bin/geeqie", at 0x5614a3b3cce0, in _start
#13   Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f6b326db304, in __libc_start_main
#12   Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f6b326db249, in 
#11   Source "/home/olaf/src/geeqie-d4c3926/build/../src/main.cc:1611", in  [0x5614a3b3afb9]
       1608:            }
       1609:        }
       1610: 
      >1611:    DEBUG_1("%s main: gtk_main", get_exec_time());
       1612:    gtk_main();
       1613: 
       1614:    gdk_threads_leave();
#10   Object "/lib/x86_64-linux-gnu/libgtk-3.so.0", at 0x7f6b34408494, in gtk_main
#9    Object "/lib/x86_64-linux-gnu/libglib-2.0.so.0", at 0x7f6b33cb1cee, in g_main_loop_run
#8    Object "/lib/x86_64-linux-gnu/libglib-2.0.so.0", at 0x7f6b33cb1a37, in 
#7    Object "/lib/x86_64-linux-gnu/libglib-2.0.so.0", at 0x7f6b33cb167e, in g_main_context_dispatch
#6    Source "/home/olaf/src/geeqie-d4c3926/build/../src/renderer-tiles.cc:1522", in gboolean rt_queue_draw_idle_cb(*gpointer data) [0x5614a3be88f8]
       1519:        }
       1520:    if (h < 1) return;
       1521: 
      >1522:    rt_tile_render(rt, it, x, y, w, h, new_data, fast);
       1523: 
       1524:    cr = cairo_create(rt->surface);
       1525:    cairo_set_source_surface(cr, it->surface, pr->x_offset + (it->x - rt->x_scroll) + rt->stereo_off_x, pr->y_offset + (it->y - rt->y_scroll) + rt->stereo_off_y);
#5    Source "/home/olaf/src/geeqie-d4c3926/build/../src/renderer-tiles.cc:1453", in rt_tile_render(RendererTiles *rt, ImageTile *it, gint x, gint y, gint w, gint h, gboolean new_data, gboolean fast) [0x5614a3be79a8]
       1450:        if (pr->width < PR_MIN_SCALE_SIZE || pr->height < PR_MIN_SCALE_SIZE) fast = TRUE;
       1451:        if (pr->image_width > 32767) wide_image = TRUE;
       1452: 
      >1453:        rt_tile_get_region(has_alpha, pr->ignore_alpha,
       1454:                   pr->pixbuf, it->pixbuf, pb_x, pb_y, pb_w, pb_h,
       1455:                   static_cast<gdouble>(0.0) - src_x - GET_RIGHT_PIXBUF_OFFSET(rt) * scale_x,
       1456:                   static_cast<gdouble>(0.0) - src_y,
#4    Source "/home/olaf/src/geeqie-d4c3926/build/../src/renderer-tiles.cc:1322", in rt_tile_get_region(gboolean has_alpha, gboolean ignore_alpha, const GdkPixbuf *src, GdkPixbuf *dest, int pb_x, int pb_y, int pb_w, int pb_h, double offset_x, double offset_y, double scale_x, double scale_y, GdkInterpType interp_type, int check_x, int check_y, gboolean wide_image) [0x5614a3be4914]
       1319:            }
       1320:        else
       1321:            {
      >1322:            gdk_pixbuf_composite_color(src, dest,
       1323:                    pb_x, pb_y, pb_w, pb_h,
       1324:                    offset_x,
       1325:                    offset_y,
#3    Object "/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0", at 0x7f6b34a65384, in gdk_pixbuf_composite_color
#2    Object "/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0", at 0x7f6b34a6abd7, in 
#1    Object "/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0", at 0x7f6b34a68ffd, in 
#0    Object "/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0", at 0x7f6b34a69a60, in 
Segmentation fault (Address not mapped to object [0x7f6ad4000003])
Segmentation fault
caclark commented 8 months ago

If you go to Edit/Preferences/Image and set Quality to Nearest, does the crash still occur?

Efenstor commented 8 months ago

If you go to Edit/Preferences/Image and set Quality to Nearest, does the crash still occur?

No, it doesn't. But the alpha channel still looks wrong in the same way.

Now, with the "Nearest" quality, I've managed to provoke another crash by keeping Geeqie open in the background, saving a photo from Gimp and then quickly switching to the just saved image in Geeqie:

Stack trace (most recent call last):
#12   Object "/usr/local/bin/geeqie", at 0x55f9c038bce0, in _start
#11   Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f4617d67304, in __libc_start_main
#10   Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f4617d67249, in 
#9    Source "/home/olaf/src/geeqie-d4c3926/build/../src/main.cc:1611", in  [0x55f9c0389fb9]
       1608:            }
       1609:        }
       1610: 
      >1611:    DEBUG_1("%s main: gtk_main", get_exec_time());
       1612:    gtk_main();
       1613: 
       1614:    gdk_threads_leave();
#8    Object "/lib/x86_64-linux-gnu/libgtk-3.so.0", at 0x7f4619a08494, in gtk_main
#7    Object "/lib/x86_64-linux-gnu/libglib-2.0.so.0", at 0x7f4619313cee, in g_main_loop_run
#6    Object "/lib/x86_64-linux-gnu/libglib-2.0.so.0", at 0x7f4619313a37, in 
#5    Object "/lib/x86_64-linux-gnu/libglib-2.0.so.0", at 0x7f461931367e, in g_main_context_dispatch
#4    Source "/home/olaf/src/geeqie-d4c3926/build/../src/renderer-tiles.cc:1522", in gboolean rt_queue_draw_idle_cb(*gpointer data) [0x55f9c04378f8]
       1519:        }
       1520:    if (h < 1) return;
       1521: 
      >1522:    rt_tile_render(rt, it, x, y, w, h, new_data, fast);
       1523: 
       1524:    cr = cairo_create(rt->surface);
       1525:    cairo_set_source_surface(cr, it->surface, pr->x_offset + (it->x - rt->x_scroll) + rt->stereo_off_x, pr->y_offset + (it->y - rt->y_scroll) + rt->stereo_off_y);
#3    Source "/home/olaf/src/geeqie-d4c3926/build/../src/renderer-tiles.cc:1453", in rt_tile_render(RendererTiles *rt, ImageTile *it, gint x, gint y, gint w, gint h, gboolean new_data, gboolean fast) [0x55f9c04369a8]
       1450:        if (pr->width < PR_MIN_SCALE_SIZE || pr->height < PR_MIN_SCALE_SIZE) fast = TRUE;
       1451:        if (pr->image_width > 32767) wide_image = TRUE;
       1452: 
      >1453:        rt_tile_get_region(has_alpha, pr->ignore_alpha,
       1454:                   pr->pixbuf, it->pixbuf, pb_x, pb_y, pb_w, pb_h,
       1455:                   static_cast<gdouble>(0.0) - src_x - GET_RIGHT_PIXBUF_OFFSET(rt) * scale_x,
       1456:                   static_cast<gdouble>(0.0) - src_y,
#2    Source "/home/olaf/src/geeqie-d4c3926/build/../src/renderer-tiles.cc:1322", in rt_tile_get_region(gboolean has_alpha, gboolean ignore_alpha, const GdkPixbuf *src, GdkPixbuf *dest, int pb_x, int pb_y, int pb_w, int pb_h, double offset_x, double offset_y, double scale_x, double scale_y, GdkInterpType interp_type, int check_x, int check_y, gboolean wide_image) [0x55f9c0433914]
       1319:            }
       1320:        else
       1321:            {
      >1322:            gdk_pixbuf_composite_color(src, dest,
       1323:                    pb_x, pb_y, pb_w, pb_h,
       1324:                    offset_x,
       1325:                    offset_y,
#1    Object "/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0", at 0x7f4619647384, in gdk_pixbuf_composite_color
#0    Object "/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0", at 0x7f461964d19b, in 
Segmentation fault (Invalid permissions for mapped object [0x7f45cafc0003])
Segmentation fault

This crash is not 100% persistent, sometimes it happens, sometimes not, but it's rather easy to provoke.

Efenstor commented 8 months ago

Yes, I can provoke it to crash 100% of time if I first display the test file (image-14-02-24-12-17.avif) and the quickly switch to any other AVIF with alpha channel: it gets stuck at drawing the last tile for a second and then crashes.

caclark commented 8 months ago

If you set zoom to 1:1 does the crash still occur?

Efenstor commented 8 months ago

If you set zoom to 1:1 does the crash still occur?

Yes it does. Here is another picture that I use for testing: P9100020.zip

It is displayed like this: Screenshot at 2024-03-01 22-19-37 Instead of this (without alpha): Screenshot at 2024-03-01 22-19-44