After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 449409 - Eog hangs when trying to open CR2 image (Canon RAW v2)
Eog hangs when trying to open CR2 image (Canon RAW v2)
Status: RESOLVED FIXED
Product: eog
Classification: Core
Component: general
2.19.x
Other Linux
: Normal major
: ---
Assigned To: EOG Maintainers
EOG Maintainers
: 439908 (view as bug list)
Depends on: 469209
Blocks: 447063
 
 
Reported: 2007-06-20 09:28 UTC by Priit Laes (IRC: plaes)
Modified: 2007-09-04 20:56 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20


Attachments
possible workaround (work-in-progress) (2.46 KB, patch)
2007-08-22 11:06 UTC, Felix Riemann
none Details | Review

Description Priit Laes (IRC: plaes) 2007-06-20 09:28:23 UTC
I have put sample file up to http://plaes.org/files/2007-Q2/img_5055.cr2

Unfortunately CR2 is one of these unsupported and undocumented file formats :(
Comment 1 Felix Riemann 2007-06-21 10:24:35 UTC
Yes, this only happens if you try to open it from the command line.
It correctly returns an error if you try it with the file-open dialog.

I suspect this could be related bug 439908.
Comment 2 Claudio Saavedra 2007-06-21 15:18:33 UTC
It looks like some locking issues. It only happens to me with trunk (2.18 returns an appropriate error message).

The traces in the place of the lock:

Program received signal SIGTSTP, Stopped (user).
[Switching to Thread -1229322560 (LWP 10141)]
0xb7fc77f2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
(gdb) thread apply all where

Thread 2 (Thread -1232364656 (LWP 10148))

  • #0 _dl_sysinfo_int80
    from /lib/ld-linux.so.2
  • #1 __lll_mutex_lock_wait
    from /lib/i686/cmov/libpthread.so.0
  • #2 _L_mutex_lock_88
    from /lib/i686/cmov/libpthread.so.0
  • #3 pthread_mutex_lock
    from /lib/i686/cmov/libpthread.so.0
  • #4 _gdk_pixbuf_lock
    at gdk-pixbuf-io.c line 108
  • #5 gdk_pixbuf_loader_load_module
    at gdk-pixbuf-loader.c line 380
  • #6 IA__gdk_pixbuf_loader_new_with_type
    at gdk-pixbuf-loader.c line 533
  • #7 load_svg_at_size
    at gtkicontheme.c line 2736
  • #8 icon_info_ensure_scale_and_pixbuf
    at gtkicontheme.c line 2794
  • #9 IA__gtk_icon_info_load_icon
    at gtkicontheme.c line 2908
  • #10 IA__gtk_icon_theme_load_icon
    at gtkicontheme.c line 1505
  • #11 icon_list_from_theme
    at gtkwindow.c line 3011
  • #12 gtk_window_realize_icon
    at gtkwindow.c line 3084
  • #13 gtk_window_realize
    at gtkwindow.c line 4643
  • #14 IA__g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #15 g_type_class_meta_marshal
    at gclosure.c line 567
  • #16 IA__g_closure_invoke
    at gclosure.c line 490
  • #17 signal_emit_unlocked_R
    at gsignal.c line 2370
  • #18 IA__g_signal_emit_valist
    at gsignal.c line 2199
  • #19 IA__g_signal_emit
    at gsignal.c line 2243
  • #20 IA__gtk_widget_realize
    at gtkwidget.c line 2851
  • #21 IA__gtk_widget_realize
    at gtkwidget.c line 2847
  • #22 IA__gtk_widget_realize
    at gtkwidget.c line 2847
  • #23 IA__gtk_widget_realize
    at gtkwidget.c line 2847
  • #24 IA__gtk_widget_realize
    at gtkwidget.c line 2847
  • #25 IA__gtk_widget_realize
    at gtkwidget.c line 2847
  • #26 eog_window_obtain_desired_size
    at eog-window.c line 1157
  • #27 eog_marshal_VOID__INT_INT
    at eog-marshal.c line 91
  • #28 IA__g_closure_invoke
    at gclosure.c line 490
  • #29 signal_emit_unlocked_R
    at gsignal.c line 2440
  • #30 IA__g_signal_emit_valist
    at gsignal.c line 2199
  • #31 IA__g_signal_emit
    at gsignal.c line 2243
  • #32 eog_image_real_load
    at eog-image.c line 943
  • #33 eog_image_load
    at eog-image.c line 1096
  • #34 eog_job_load_run
    at eog-jobs.c line 313
  • #35 eog_render_thread
    at eog-job-queue.c line 78
  • #36 g_thread_create_proxy
    at gthread.c line 594
  • #37 start_thread
    from /lib/i686/cmov/libpthread.so.0
  • #38 clone
    from /lib/i686/cmov/libc.so.6

Comment 3 Felix Riemann 2007-06-21 15:56:20 UTC
Interesting.

Just comment out the

gtk_window_set_default_icon_name ("eog");

line in main.c and the window is displayed and shows the error (although it seems to eat the whole file first). It even opens SVGs (bug 439908).

I wonder where the actual error is to find (eog, gdk-pixbuf, librsvg).



By the way, your trace has some similarities in the upmost frames with the one I got in bug 447063, which seems to be worked-around by that too (although it doesn't display correctly).
Comment 4 Matthias Clasen 2007-06-21 16:28:42 UTC
Yeah, this is a pretty bad problem, with no easy solution right now.

The problem is that some of the image libraries used by gdk-pixbuf are not
threadsafe. Therefore, we have introduced locking some time ago. What is
happening now is the following:

- eog creates a pixbuf loader for incrementally loading the unsuppored
  image; for some reason gdk-pixbuf decides to try the non-threadsafe
  tiff loader for it. Thus it locks the gdk-pixbuf lock.

- while feeding data to the loader, eog emits some signals that cause
  ui to be constructed
 
- most images loaded during the ui construction are pngs and the
  png module is threadsafe. 

- but some are svg, and the svg loader is not threadsafe, thus gdk-pixbuf
  tries to lock again, and blocks on the lock taken earlier.
Comment 5 Matthias Clasen 2007-06-21 16:54:23 UTC
I don't have a very good solution to offer right now. You are having bad luck here, the tiff loader is the only builtin loader that is not threadsafe.

Here is a thread with some hints on the libtiff <> threads situation:
http://www.anonymouse.ru/cgi-bin/nph-proxy_ru.cgi/000111A/http/www.asmail.be/msg0054568393.html

Looking at that it may be possible to rework the tiff loader to be threadsafe,
but it is going to require some work.

In the meantime, all we could do is offer a gdk_pixbuf_loader_is_locked() api
that you could use to avoid the deadlock...
Comment 6 Claudio Saavedra 2007-06-21 17:03:09 UTC
*** Bug 439908 has been marked as a duplicate of this bug. ***
Comment 7 Felix Riemann 2007-06-26 21:01:16 UTC
Hmm, would it suffice to assign the tiff context (or whatever object is required to do error reporting) to a GStaticPrivate object and retrieve it in the error_handler?

Somewhat like this:

static GStaticPrivate thread_context;

...
error_handler ()
{
   Context ctx = g_static_private_get (thread_context)
...
   report_error (ctx, error);
...
}

init_func ()
{
   Context ctx = new_context ();

...
   g_static_private_set (thread_context, ctx);
...
}

Otherwise I don't have any other idea on how to solve that; even the current development versions of libtiff seem to have this ugly way of error reporting.
Comment 8 Felix Riemann 2007-06-26 21:05:15 UTC
Just noticed that this would still not fix it if you'd try to use two such loaders from the same thread. :-(
Comment 9 Felix Riemann 2007-08-22 11:06:18 UTC
Created attachment 94098 [details] [review]
possible workaround (work-in-progress)

This a work-in-progress patch to workaround those threadunsafe loaders. It simply  tries to delay the emission of the EogImage:size-prepared signal until the loader has finished. Seems to work good so far. The only downside is that the UI shows up after having completed loading (as in EOG < 2.19)
.
It currently uses the GdkPixbufFormat structure directly because there is no accessor function yet for the thread-safety attribute, but I'm going to prepare a patch for GTK+ to change that.
Comment 10 Felix Riemann 2007-08-22 11:42:14 UTC
GTK+ bug to add gdk_pixbuf_format_is_threadsafe(): bug 469209
Comment 11 Sebastien Bacher 2007-09-04 08:16:14 UTC
GNOME 2.20.0 code freeze is next week and eog is still hanging when trying to open a svg
Comment 12 Lucas Rocha 2007-09-04 20:56:27 UTC
Ok, I refactored Felix' patch (Thanks Felix!) and it really seems to work around this non-threadsafe loader problem. Fixed in trunk.

2007-09-04  Lucas Rocha  <lucasr@gnome.org>

        * src/eog-image-private.h: added threadsafe_format private attribute.
        * src/eog-image.c (+eog_image_pre_size_prepared,
        eog_image_size_prepared, eog_image_real_load): detect non-threadsafe
        loaders and disable any possible asyncronous task that could bring
        deadlocks to image loading process. Fixes bug #449409 (Felix Riemann).