GNOME Bugzilla – Bug 747349
Conversion of gdbus to use GTask causes deadlocks
Last modified: 2015-04-06 16:22:27 UTC
The conversion of gdbus to use GTask seems to frequently cause deadlocks when refreshing a remote share in Nautilus (i.e. using gvfs). I haven't yet had the time to dig into the cause. Example backtrace: (gdb) thread apply all bt
+ Trace 234940
Thread 2 (Thread 0x7fab4f499700 (LWP 4045))
Thread 1 (Thread 0x7fab5e05b940 (LWP 4043))
I suppose the problem is that send_message_with_reply_cancelled_idle_cb takes the connection lock and ends up calling the application callback with the lock still held.
Created attachment 301022 [details] [review] gdbus: fix deadlock on message cancel/timeout The gdbus GTask port introduced a deadlock because some code had been using g_simple_async_result_complete_in_idle() to ensure that the callback didn't run until after a mutex was unlocked, but in the gtask version, the callback was being run immediately. Fix it to drop the mutex before calling g_task_return*(). Also, tweak tests/gdbus-connection to test this.
(In reply to Dan Winship from comment #2) > Created attachment 301022 [details] [review] [review] > gdbus: fix deadlock on message cancel/timeout > > The gdbus GTask port introduced a deadlock because some code had been > using g_simple_async_result_complete_in_idle() to ensure that the > callback didn't run until after a mutex was unlocked, but in the gtask > version, the callback was being run immediately. Fix it to drop the > mutex before calling g_task_return*(). Also, tweak > tests/gdbus-connection to test this. Well that seems to fix the hangs. Thanks
Review of attachment 301022 [details] [review]: Looks good. Thanks for updating the tests to cover this. ::: gio/gdbusconnection.c @@ +1858,3 @@ + G_IO_ERROR, + G_IO_ERROR_CANCELLED, + _("Operation was cancelled")); I slightly prefer these on one line, but no big deal either way
Attachment 301022 [details] pushed as 7e8d414 - gdbus: fix deadlock on message cancel/timeout