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 688751 - Deadlock in gnutls
Deadlock in gnutls
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: network
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 693320 (view as bug list)
Depends on:
Blocks: 689642
 
 
Reported: 2012-11-20 20:24 UTC by Giovanni Campagna
Modified: 2016-07-12 15:44 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Giovanni Campagna 2012-11-20 20:24:55 UTC
Recently I've started seeing deadlocks in liferea, and I tracked them down to glib-networking (through soup and webkit).

The blocking call is the g_poll() for the cancellables in claim_op(CLOSING), which can't be satisfied because no gnutls thread is running. reading, read_blocking, writing, write_blocking flags are all 1.
handshaking is also 1, but ever_handshaked is 1 and need_handshake is 0

A reduced backtrace follows:

Thread 1 (Thread 0x7f71846c69c0 (LWP 28275))

  • #0 poll
    at ../sysdeps/unix/syscall-template.S line 81
  • #1 g_poll
    at gpoll.c line 132
  • #2 claim_op
    at gtlsconnection-gnutls.c line 583
  • #3 g_tls_connection_gnutls_close
    at gtlsconnection-gnutls.c line 1449
  • #4 g_io_stream_close
    at giostream.c line 414
  • #5 disconnect_internal
    at soup-socket.c line 116
  • #6 soup_socket_disconnect
    at soup-socket.c line 1226
  • #7 soup_connection_disconnect
    at soup-connection.c line 835
  • #8 soup_connection_set_state
    at soup-connection.c line 916
  • #9 soup_session_unqueue_item
    at soup-session.c line 1387
  • #10 process_queue_item
    at soup-session-async.c line 267
  • #11 soup_session_async_cancel_message
    at soup-session-async.c line 425
  • #12 soup_session_cancel_message
    at soup-session.c line 1710
  • #13 WebCore::ResourceLoader::cancel(WebCore::ResourceError const&)
    from /opt/gnome/lib64/libwebkitgtk-3.0.so.0


The other threads are webkit GCs, glib, dconf, gdbus, webkit icondb, plus a GThreadPool waiting for more stuff.

I suspected a race condition in the way the GWakeup is set up for the waiting_for_op GCancellable, so tried to move that inside the mutex, but it didn't help.
Comment 1 Dan Winship 2012-11-26 20:40:40 UTC
Can you try inserting a

  g_cancellable_cancel (gnutls->priv->waiting_for_op);

after the

  gnutls->priv->handshaking = FALSE;

in the need_finish_handshaking condition in claim_op? (ie, roughly line 551)
Comment 2 Giovanni Campagna 2012-11-26 20:55:53 UTC
Nope, still the same deadlock.
Comment 3 Dan Winship 2012-12-04 17:31:41 UTC
I think stefw may have fixed this in glib-networking master:
http://git.gnome.org/browse/glib-networking/commit/?id=58fd3d53
Comment 4 Debarshi Ray 2012-12-05 17:03:18 UTC
It is still hanging for me with the following backtrace:

  • #0 poll
    at ../sysdeps/unix/syscall-template.S line 81
  • #1 poll
    at /usr/include/bits/poll2.h line 46
  • #2 g_poll
    at gpoll.c line 132
  • #3 claim_op
    at gtlsconnection-gnutls.c line 583
  • #4 g_tls_connection_gnutls_close
    at gtlsconnection-gnutls.c line 1449
  • #5 g_io_stream_close
    at giostream.c line 414
  • #6 disconnect_internal
    at soup-socket.c line 116
  • #7 soup_socket_disconnect
    at soup-socket.c line 1226
  • #8 soup_connection_disconnect
    at soup-connection.c line 831
  • #9 soup_session_abort
    at soup-session.c line 1677
  • #10 _g_closure_invoke_va
    at gclosure.c line 840
  • #11 g_signal_emit_valist
    at gsignal.c line 3226
  • #12 g_signal_emit
    at gsignal.c line 3371
  • #13 g_cancellable_cancel
    at gcancellable.c line 507

Here is a test case: http://rishi.fedorapeople.org/gtls-cancel.tar.gz
Hangs on every 2nd attempt on my system.
Comment 5 Dan Winship 2012-12-09 15:35:57 UTC
Fixed in master. I think I might put out another stable release for
this, after its gotten a little bit of testing.
Comment 6 Debarshi Ray 2016-07-12 15:44:58 UTC
*** Bug 693320 has been marked as a duplicate of this bug. ***