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 691399 - Deadlock with sync session under soup_session_abort() called from the main thread
Deadlock with sync session under soup_session_abort() called from the main th...
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: Misc
2.40.x
Other Linux
: Normal major
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2013-01-09 12:12 UTC by Milan Crha
Modified: 2013-02-06 13:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test.c (1.49 KB, text/plain)
2013-01-09 21:39 UTC, Milan Crha
Details

Description Milan Crha 2013-01-09 12:12:40 UTC
I'm on libsoup's git master at commit 1ac2f9dedf6333438698 and I get this freeze in evolution-calendar-factory. Note this is a SoupSessionSync, thus I guess I should see its activity in other threads.

Thread 1 (Thread 0x7f3fb2262980 (LWP 21269))

  • #0 pthread_cond_wait
    from /lib64/libpthread.so.0
  • #1 g_cond_wait
    at gthread-posix.c line 750
  • #2 soup_session_real_flush_queue
    at soup-session.c line 2283
  • #3 soup_session_abort
    at soup-session.c line 2315
  • #4 soup_session_set_property
    at soup-session.c line 566
  • #5 object_set_property
    at gobject.c line 1358
  • #6 g_object_set_valist
    at gobject.c line 1953
  • #7 g_object_set
    at gobject.c line 2059
  • #8 cal_backend_http_ensure_uri
    at e-cal-backend-http.c line 743
  • #9 source_changed_cb
    at e-cal-backend-http.c line 812
  • #10 g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 85
  • #11 g_closure_invoke
    at gclosure.c line 777
  • #12 signal_emit_unlocked_R
    at gsignal.c line 3567
  • #13 g_signal_emit_valist
    at gsignal.c line 3315
  • #14 g_signal_emit
    at gsignal.c line 3371
  • #15 source_idle_changed_cb
    at e-source.c line 682
  • #16 g_idle_dispatch
    at gmain.c line 4887
  • #17 g_main_dispatch
    at gmain.c line 2784
  • #18 g_main_context_dispatch
    at gmain.c line 3288
  • #19 g_main_context_iterate
    at gmain.c line 3359
  • #20 g_main_loop_run
    at gmain.c line 3553
  • #21 dbus_server_run_server
    at e-dbus-server.c line 222
  • #22 ffi_call_unix64
    from /lib64/libffi.so.5
  • #23 ffi_call
    from /lib64/libffi.so.5
  • #24 g_cclosure_marshal_generic_va
    at gclosure.c line 1550
  • #25 g_type_class_meta_marshalv
    at gclosure.c line 997
  • #26 _g_closure_invoke_va
    at gclosure.c line 840
  • #27 g_signal_emit_valist
    at gsignal.c line 3226
  • #28 g_signal_emit
    at gsignal.c line 3371
  • #29 e_dbus_server_run
    at e-dbus-server.c line 396
  • #30 main
    at evolution-calendar-factory.c line 137

Comment 1 Dan Winship 2013-01-09 14:09:31 UTC
Is this reliable/sporadic/one-time-only? I just tried reproducing but couldn't.
Comment 2 Milan Crha 2013-01-09 14:21:38 UTC
I tried with get.c and I cannot too, but in eds it crashes. It seems to me that it's something with GLib and its signal disconnection - see the source_changed_cb(). It seems like the backend is already disposed, but it disconnects from that signal in that time... I'm investigating further.
Comment 3 Milan Crha 2013-01-09 14:33:30 UTC
Err, some race condition in eds, the backend was freed inside the crashing function, thus this lead to use-after-free. I did not notice this with stable GLib/GIO, thus maybe it's caused by delays and thread schedule or something, but when I add and remove a reference in the source_changed_cb() to the backend, then it doesn't crash. In any way, this is not a libsoup bug. I'm sorry for a false alarm.
Comment 4 Milan Crha 2013-01-09 18:05:42 UTC
Hrm, it wasn't it, I get the freeze in soup_session_abort() on the property set even with the backend being reffed. The session has one pending item. I'll investigate further and if I find anything on the libsoup side, then I'll update the bug.
Comment 5 Dan Winship 2013-01-09 18:45:23 UTC
it's possible some message has gotten "stranded" somehow, so that it will never complete... would want to see what its SoupMessageQueueItem looked like...
Comment 6 Milan Crha 2013-01-09 21:39:15 UTC
Created attachment 233113 [details]
test.c

I'm reopening this. Here's a reproducer, just simple libsoup. The first line contains a command to compile and run it. The deadlock looks like:
>   waiting one second in main idle
>      about to send the message at a thread
>   done with wait one second in main idle, setting proxy to NULL
>      finished the message send at a thread

I see this with libsoup-2.40.2-1.fc18.x86_64, thus I'm changing the version as well.
Comment 7 Milan Crha 2013-01-09 21:43:32 UTC
Just verified that the line
> g_object_set (session, "proxy-uri", NULL, NULL);
in the test.c can be replaced with
> soup_session_abort (session);
and it'll deadlock too.
Comment 8 Dan Winship 2013-01-09 22:28:17 UTC
I had to modify the test case to decrease the timeout each round; for me, the deadlock tended to happen at around .5 seconds.

Fixed in master. For 2.40, I believe that adding "g_cond_broadcast (priv->cond);" after the soup_session_unqueue_item() call in soup-session-sync.c's process_queue_item() should fix it. Can you try that?

(I'm thinking I'll put out a 2.40 release along with the 2.41 release next week.)
Comment 9 Milan Crha 2013-01-10 13:41:07 UTC
OK, I changed it to:
    g_cond_broadcast (&priv->cond);
and it helped, it doesn't freeze anymore (I left it running for several cycles and it didn't freeze, while it would freeze in the first or max the ~5th cycle without the change).
Comment 10 Dan Winship 2013-02-06 13:30:24 UTC
belatedly closing; this is fixed in master and 2.40.3