Bug 64923

Summary: 100% cpu usage
Product: Telepathy Reporter: Age Bosma (IRC: Forage) <age.bosma>
Component: idleAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: ServerConnection: kill async read when disconnecting
ServerConnection: dispose internal objects

Description Age Bosma (IRC: Forage) 2013-05-23 15:59:49 UTC
Downstream bug: https://bugs.launchpad.net/ubuntu/+source/telepathy-idle/+bug/1149506

0.1.14 eats up 100% cpu. Possible regression of #34166 and/or #48084?
Comment 1 Jussi Kukkonen 2013-08-23 12:13:56 UTC
I'm seeing this with telepathy-idle 0.1.16 on Debian (and have seen it earlier as well). It is common enough to be a real pain in the ass... Often it happens in relation to some short term network problems, and the result is telepathy-idle hogging 100% of one core -- seemingly forever.

Looks like this:

(gdb) thread apply all bt

Thread 3 (Thread 0x7f46b959e700 (LWP 3633)):
#0  0x00007f46bc36e19d in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007f46bccdb5c4 in g_main_context_poll (priority=2147483647, n_fds=1, fds=0x7f46980010c0, 
    timeout=-1, context=0x7f46b400aca0) at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gmain.c:4006
#2  g_main_context_iterate (context=context@entry=0x7f46b400aca0, block=block@entry=1, 
    dispatch=dispatch@entry=1, self=<optimized out>)
    at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gmain.c:3707
#3  0x00007f46bccdb6cc in g_main_context_iteration (context=0x7f46b400aca0, may_block=1)
    at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gmain.c:3773
#4  0x00007f46b95a5a1d in ?? () from /usr/lib/x86_64-linux-gnu/gio/modules/libdconfsettings.so
#5  0x00007f46bcd00275 in g_thread_proxy (data=0x7f46b4003400)
    at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gthread.c:798
#6  0x00007f46bc644e0e in start_thread (arg=0x7f46b959e700) at pthread_create.c:311
#7  0x00007f46bc37993d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 2 (Thread 0x7f4697bea700 (LWP 3638)):
#0  0x00007f46bc36e19d in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007f46bccdb5c4 in g_main_context_poll (priority=2147483647, n_fds=3, fds=0x7f46900010c0, 
    timeout=-1, context=0x7f469800e520) at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gmain.c:4006
#2  g_main_context_iterate (context=0x7f469800e520, block=block@entry=1, dispatch=dispatch@entry=1, 
    self=<optimized out>) at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gmain.c:3707
#3  0x00007f46bccdba2a in g_main_loop_run (loop=0x7f4698010350)
    at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gmain.c:3906
#4  0x00007f46bd2b9956 in gdbus_shared_thread_func (user_data=0x7f469800e4f0)
    at /build/glib2.0-U55j9q/glib2.0-2.37.6/./gio/gdbusprivate.c:278
#5  0x00007f46bcd00275 in g_thread_proxy (data=0x7f46a40026d0)
    at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gthread.c:798
#6  0x00007f46bc644e0e in start_thread (arg=0x7f4697bea700) at pthread_create.c:311
#7  0x00007f46bc37993d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 1 (Thread 0x7f46bdbb4800 (LWP 3626)):
#0  g_mutex_get_impl (mutex=0x25264e0)
    at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gthread-posix.c:126
#1  0x00007f46bcd1b519 in g_mutex_lock (mutex=mutex@entry=0x25264e0)
    at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gthread-posix.c:213
#2  0x00007f46bccdac79 in g_main_context_prepare (context=context@entry=0x25264e0, 
    priority=priority@entry=0x7fffdd286698) at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gmain.c:3341
#3  0x00007f46bccdb4e3 in g_main_context_iterate (context=0x25264e0, block=block@entry=1, 
    dispatch=dispatch@entry=1, self=<optimized out>)
    at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gmain.c:3692
#4  0x00007f46bccdba2a in g_main_loop_run (loop=0x2529310)
    at /build/glib2.0-U55j9q/glib2.0-2.37.6/./glib/gmain.c:3906
#5  0x00007f46bc9a5ca2 in tp_run_connection_manager ()
   from /usr/lib/x86_64-linux-gnu/libtelepathy-glib.so.0
#6  0x000000000040a326 in ?? ()
#7  0x00007f46bc2b2995 in __libc_start_main (main=0x40a2e0, argc=1, ubp_av=0x7fffdd286838, 
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffdd286828)
    at libc-start.c:260
#8  0x000000000040a361 in ?? ()
#9  0x00007fffdd286828 in ?? ()
#10 0x0000000000000000 in ?? ()


Threads 2 and 3 seem to stay the same, thread 1 is occasionally in a libdbus call as well (at least dbus_connection_get_dispatch_status()).
Comment 2 Age Bosma (IRC: Forage) 2013-08-23 13:32:22 UTC
I can confirm the issue occurring in 0.1.16 as well.

In my case it happens as soon as I login to freenode with a password.

Let me know if and how I need to create a log.
Comment 3 Lionel Landwerlin 2013-08-29 23:01:01 UTC
Created attachment 84885 [details] [review]
ServerConnection: kill async read when disconnecting

This is the fix.
Comment 4 Lionel Landwerlin 2013-08-29 23:02:06 UTC
Created attachment 84886 [details] [review]
ServerConnection: dispose internal objects

That's just a cleanup.
Comment 5 Lionel Landwerlin 2013-08-29 23:37:47 UTC
I also filed https://bugzilla.gnome.org/show_bug.cgi?id=707097 on GSocket, it seems a different default behavior from GSocket would be welcome.
Comment 6 Simon McVittie 2013-09-05 12:22:15 UTC
Patches look good, I'll merge them (with s/g_clear_object/tp_clear_object/ if we don't already depend on a suitable GLib).
Comment 7 Simon McVittie 2013-09-05 13:33:28 UTC
Fixed in git for 0.1.18, thanks

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.