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 586432 - deadlock in gio/tests/unix-streams (cancellation vs _g_fd_source)
deadlock in gio/tests/unix-streams (cancellation vs _g_fd_source)
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2009-06-19 21:10 UTC by Dan Winship
Modified: 2010-08-03 14:44 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dan Winship 2009-06-19 21:10:58 UTC
(gdb) thread 1
[Switching to thread 1 (Thread 0xb7fd7930 (LWP 17631))]#0  0x00d1c424 in __kernel_vsyscall ()
(gdb) bt
  • #0 __kernel_vsyscall
  • #1 pthread_cond_wait
    at ../nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S line 122
  • #2 IA__g_cancellable_disconnect
    at gcancellable.c line 626
  • #3 fd_source_finalize
    at gasynchelper.c line 96
  • #4 g_source_unref_internal
    at gmain.c line 1317
  • #5 g_main_dispatch
    at gmain.c line 1971
  • #6 IA__g_main_context_dispatch
    at gmain.c line 2495
  • #7 g_main_context_iterate
    at gmain.c line 2573
  • #8 IA__g_main_loop_run
    at gmain.c line 2781
  • #9 test_pipe_io
    at unix-streams.c line 232
  • #10 test_case_run
    at gtestutils.c line 1130
  • #11 g_test_run_suite_internal
    at gtestutils.c line 1179
  • #12 g_test_run_suite_internal
    at gtestutils.c line 1189
  • #13 IA__g_test_run_suite
    at gtestutils.c line 1230
  • #14 IA__g_test_run
    at gtestutils.c line 862
  • #15 main
    at unix-streams.c line 255
  • #0 __kernel_vsyscall
  • #1 __lll_lock_wait
    at ../nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S line 142
  • #2 _L_lock_752
    from /lib/libpthread.so.0
  • #3 __pthread_mutex_lock
    at pthread_mutex_lock.c line 61
  • #4 IA__g_main_context_wakeup
    at gmain.c line 3194
  • #5 fd_source_cancelled_cb
    at gasynchelper.c line 119
  • #6 IA__g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 77
  • #7 IA__g_closure_invoke
    at gclosure.c line 767
  • #8 signal_emit_unlocked_R
    at gsignal.c line 3247
  • #9 IA__g_signal_emit_valist
    at gsignal.c line 2980
  • #10 IA__g_signal_emit
    at gsignal.c line 3037
  • #11 IA__g_cancellable_cancel
    at gcancellable.c line 518
  • #12 writer_thread
    at unix-streams.c line 67
  • #13 g_thread_create_proxy
    at gthread.c line 635
  • #14 start_thread
    at pthread_create.c line 297
  • #15 clone
    at ../sysdeps/unix/sysv/linux/i386/clone.S line 130

That is, thread 1 (the main thread) is in a main loop callback (thus holding the GMainContext's lock) where it is waiting for main_cancel to finish cancelling so it can disconnect from it. Thread 3 is in the midst of emitting "cancelled" on main_cancel, and as part of that needs to acquire the GMainContext's lock so it can wake it up.
Comment 1 Matthias Clasen 2010-07-29 04:32:40 UTC
I think the easiest fix for this would be to make fd_source_finalize not block, by using g_signal_handler_disconnect instead of g_cancellable_disconnect ?
Comment 2 Dan Winship 2010-08-03 13:12:46 UTC
I see you already committed a fix to unix-streams.c

When I filed the bug, shortly after bug 572844 was committed, I was worried that it indicated a general problem with g_cancellable_connect/disconnect that would pop up in other places as well. I guess it didn't.
Comment 3 Matthias Clasen 2010-08-03 14:17:40 UTC
Well, I committed a workaround to stop the test from hanging

I still think this ought to be fixed in gasynchelper.c