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 656682 - Empathy exits due to problem in the main loop exits with "Too many open files"
Empathy exits due to problem in the main loop exits with "Too many open files"
Status: RESOLVED FIXED
Product: empathy
Classification: Core
Component: Meta Contacts
unspecified
Other Linux
: Normal normal
: 3.2
Assigned To: empathy-maint
Depends on:
Blocks:
 
 
Reported: 2011-08-16 17:42 UTC by Raul Gutierrez Segales
Modified: 2011-08-26 09:12 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Raul Gutierrez Segales 2011-08-16 17:42:27 UTC
Running master Empathy dies with this every once in a while:

GLib-ERROR **: Cannot create eventfd for main loop wake-up: Too many open files

Program received signal SIGTRAP, Trace/breakpoint trap.
g_logv (log_domain=0x35518aec46 "GLib", log_level=<optimized out>, format=
    0x35518b54c0 "Cannot create eventfd for main loop wake-up: %s", args1=0x7fffffffd508)
    at gmessages.c:559


  • #0 g_logv
    at gmessages.c line 559
  • #1 g_log
    at gmessages.c line 573
  • #2 g_main_context_init_pipe
    at gmain.c line 580
  • #3 g_main_context_new
    at gmain.c line 678
  • #4 g_dbus_connection_send_message_with_reply_sync
    at gdbusconnection.c line 2005
  • #5 g_dbus_connection_call_sync
    at gdbusconnection.c line 5308
  • #6 g_dbus_proxy_call_sync
    at gdbusproxy.c line 2672
  • #7 notify_notification_show
    at notification.c line 596
  • #8 update_notification
    at empathy-notifications-approver.c line 415
  • #9 g_closure_invoke
    at gclosure.c line 773
  • #10 signal_emit_unlocked_R
    at gsignal.c line 3256
  • #11 g_signal_emit_valist
    at gsignal.c line 2987
  • #12 g_signal_emit
    at gsignal.c line 3044
  • #13 event_manager_add
    at empathy-event-manager.c line 261
  • #14 event_manager_chat_message_received_cb
    at empathy-event-manager.c line 615
  • #15 approve_channels
    at empathy-event-manager.c line 1080
  • #16 add_dispatch_operation
    at simple-approver.c line 197
  • #17 add_dispatch_context_prepare_cb
    at base-client.c line 1765
  • #18 g_simple_async_result_complete
    at gsimpleasyncresult.c line 749

Comment 1 Guillaume Desmottes 2011-08-17 08:22:47 UTC
Interesting, I guess we leak fd somewhere. Could you please use strace or a similar tool to check what are those files?
Comment 2 Guillaume Desmottes 2011-08-22 12:48:50 UTC
I managed to reproduce this. I had 1000 avatar files opened.
Comment 3 Guillaume Desmottes 2011-08-22 13:41:00 UTC
I really suspect this has been introduced by Folks's cache backend. We didn't change any avatar related code in Empathy or tp-glib. Can you please double check if folks isn't leaking any fd?
Comment 4 Philip Withnall 2011-08-22 23:40:34 UTC
(In reply to comment #3)
> I really suspect this has been introduced by Folks's cache backend. We didn't
> change any avatar related code in Empathy or tp-glib. Can you please double
> check if folks isn't leaking any fd?

It could also be this code, though I can't see any way it could leak an fd. (It doesn't explicitly close the input stream, but GInputStream is supposed to close its FD when it's finalised, so that should be OK…unless we're leaking the input stream.)

http://git.gnome.org/browse/empathy/commit/?id=3a9a3210bbf8e927ef64510d066c035aa60a8a50
Comment 5 Philip Withnall 2011-08-23 22:50:27 UTC
Turns out it was that code, though the leak wasn't entirely our fault. See bug #657206 for the problem in GIO which caused it.

I've worked around it in Empathy by explicitly closing the input stream, so at the worst we'll just leak the input stream object rather than its FD.

commit 57075092737c287010e1a2435bf1b1c1839101a5
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Tue Aug 23 23:42:52 2011 +0100

    libempathy-gtk: Explicitly close the input stream used for reading avatars
    
    Due to a missing unref in GIO, the input stream is leaked by GFileIcon, so
    if we rely on its FD being implicitly closed when the stream is finalised,
    we'll end up leaking (lots of) file descriptors.
    
    As well as fixing the unref in GIO (see: bgo#657206), we now explicitly
    close the input stream so that even if the stream object is leaked, the FD
    isn't.
    
    Closes: bgo#656682

 libempathy-gtk/empathy-ui-utils.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
Comment 6 Raul Gutierrez Segales 2011-08-25 11:43:39 UTC
Running master I am still getting this:

GLib-ERROR **: Cannot create eventfd for main loop wake-up: Too many open files

Program received signal SIGTRAP, Trace/breakpoint trap.
g_logv (log_domain=0x33a7caec46 "GLib", log_level=<optimized out>, format=0x33a7cb54c0 "Cannot create eventfd for main loop wake-up: %s", args1=0x7fffffffd528) at gmessages.c:559
559		  g_private_set (g_log_depth, GUINT_TO_POINTER (depth));
(gdb) bt
  • #0 g_logv
    at gmessages.c line 559
  • #1 g_log
    at gmessages.c line 573
  • #2 g_main_context_init_pipe
    at gmain.c line 580
  • #3 g_main_context_new
    at gmain.c line 678
  • #4 g_dbus_connection_send_message_with_reply_sync
    at gdbusconnection.c line 2005
  • #5 g_dbus_connection_call_sync
    at gdbusconnection.c line 5308
  • #6 g_dbus_proxy_call_sync
    at gdbusproxy.c line 2672
  • #7 notify_notification_show
    at notification.c line 596
  • #8 update_notification
    at empathy-notifications-approver.c line 415
  • #9 g_closure_invoke
    at gclosure.c line 773
  • #10 signal_emit_unlocked_R
    at gsignal.c line 3256
  • #11 g_signal_emit_valist
    at gsignal.c line 2987
  • #12 g_signal_emit
    at gsignal.c line 3044
  • #13 event_manager_add
    at empathy-event-manager.c line 260
  • #14 event_manager_chat_message_received_cb
    at empathy-event-manager.c line 614
  • #15 approve_channels
    at empathy-event-manager.c line 1079
  • #16 add_dispatch_operation
    at simple-approver.c line 197
  • #17 add_dispatch_context_prepare_cb
    at base-client.c line 1869
  • #18 g_simple_async_result_complete
    at gsimpleasyncresult.c line 749
  • #19 context_check_prepare
    at add-dispatch-operation-context.c line 449
  • #20 context_check_prepare
    at add-dispatch-operation-context.c line 443
  • #21 adoc_channel_prepare_cb
    at add-dispatch-operation-context.c line 547
  • #22 g_simple_async_result_complete
    at gsimpleasyncresult.c line 749
  • #23 complete_in_idle_cb
    at gsimpleasyncresult.c line 761
  • #24 g_main_dispatch
    at gmain.c line 2500
  • #25 g_main_context_dispatch
    at gmain.c line 3083
  • #26 g_main_context_iterate
    at gmain.c line 3161
  • #27 g_main_loop_run
    at gmain.c line 3369
  • #28 gtk_main
    at gtkmain.c line 1358
  • #29 g_application_run
    at gapplication.c line 1325
  • #30 main
    at empathy.c line 788

Comment 7 Raul Gutierrez Segales 2011-08-25 16:02:35 UTC
Pre-crashing messages:

[Thread 0x7fffdadf0700 (LWP 9527) exited]
[New Thread 0x7fffdadf0700 (LWP 14290)]
I/O error : Too many open files
I/O error : Too many open files
Comment 8 Raul Gutierrez Segales 2011-08-25 21:47:35 UTC
And yes, I still have a zillion avatar files open:

ls -lah /proc/EMPATHY_PID/fd/
total 0
dr-x------ 2 rgs rgs  0 Aug 25 18:56 .
dr-xr-xr-x 8 rgs rgs  0 Aug 25 18:37 ..
lrwx------ 1 rgs rgs 64 Aug 25 18:56 0 -> /dev/pts/4
lrwx------ 1 rgs rgs 64 Aug 25 18:56 1 -> /dev/pts/4
lrwx------ 1 rgs rgs 64 Aug 25 18:56 10 -> socket:[179554523]
lr-x------ 1 rgs rgs 64 Aug 25 18:56 100 -> /debian/rgs/.cache/telepathy/avatars/butterfly/msn/f70cfdffa9008de13f85015d24ba052d287a0dfd
lr-x------ 1 rgs rgs 64 Aug 25 22:43 1000 -> /debian/rgs/.cache/telepathy/avatars/gabble/jabber/_37755b577f0fae920651bb27362924b6792ad24fd
lr-x------ 1 rgs rgs 64 Aug 25 22:43 1001 -> /debian/rgs/.cache/telepathy/avatars/gabble/jabber/_393cdac4409b8c598c1df2fc45575e502b5b77e92
lr-x------ 1 rgs rgs 64 Aug 25 22:43 1002 -> /debian/rgs/.cache/telepathy/avatars/gabble/jabber/ac0e051c346dda727d8dc1fc8d34e0ab9aa79043

..

ls -lah /proc/EMPATHY_PID/fd/ | grep avatars | wc -l 

999
Comment 9 Raul Gutierrez Segales 2011-08-26 09:12:51 UTC
I was actually running empathy without the needed patch - with Philip's patch life is good again. Sorry for the noise.