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 732925 - Allow sync and async methods to be called with the same GMainContext
Allow sync and async methods to be called with the same GMainContext
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: Misc
2.47.x
Other Linux
: Normal normal
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2014-07-08 22:12 UTC by Ross Lagerwall
Modified: 2014-07-19 15:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
soup-session: Only process async items from async_run_queue (1.03 KB, patch)
2014-07-08 22:16 UTC, Ross Lagerwall
committed Details | Review
program to reproduce the problem (3.21 KB, text/x-csrc)
2014-07-08 22:24 UTC, Ross Lagerwall
  Details

Description Ross Lagerwall 2014-07-08 22:12:23 UTC
Since gvfs was ported to use a single SoupSession for sync and async methods, the webdav backend fails when performing concurrent operations.

This is because the operations are run from different threads with the same thread-default GMainContext.

It would be nice if this worked OK (I don't see why the GMainContext should matter for the sync methods of SoupSession).

Thanks
Comment 1 Ross Lagerwall 2014-07-08 22:16:56 UTC
Created attachment 280196 [details] [review]
soup-session: Only process async items from async_run_queue

Only process async items from async_run_queue to allow sync and async
methods to run concurrently in separate threads with the same
async_context.
Comment 2 Ross Lagerwall 2014-07-08 22:23:43 UTC
The attached patch fixes the issue for me.

I have attached a test program which demonstrates the problem (this may require the patch from bug 732783 to be applied).

Sample output:
$ ./concurrent2
GLib-GIO-Message: Using the 'memory' GSettings backend.  Your settings will not be saved or shared with other applications.

(process:3604): libsoup-WARNING **: (soup-session.c:2009):soup_session_process_queue_item: runtime check failed: (item->async)

(process:3604): libsoup-WARNING **: (soup-session.c:1977):soup_session_process_queue_item: runtime check failed: (item->new_api)

(process:3604): libsoup-CRITICAL **: soup_connection_get_ever_used: assertion 'SOUP_IS_CONNECTION (conn)' failed

(process:3604): libsoup-CRITICAL **: soup_message_queue_remove: assertion '!item->removed' failed
Segmentation fault (core dumped)


gdb backtrace at the point of the first warning:

Thread 2 (Thread 0x7ffff56a3700 (LWP 3593))

  • #0 g_hash_table_lookup
    at ghash.c line 1086
  • #1 param_spec_ht_lookup
    at gparam.c line 1002
  • #2 g_param_spec_pool_lookup
    at gparam.c line 1078
  • #3 g_object_notify
    at gobject.c line 1183
  • #4 object_set_property
    at gobject.c line 1378
  • #5 g_object_new_internal
    at gobject.c line 1757
  • #6 g_object_newv
    at gobject.c line 1868
  • #7 g_object_new
    at gobject.c line 1568
  • #8 new_socket_client
    at soup-socket.c line 862
  • #9 soup_socket_connect_sync_internal
    at soup-socket.c line 1033
  • #10 soup_connection_connect_sync
    at soup-connection.c line 479
  • #11 get_connection
    at soup-session.c line 1920
  • #12 soup_session_process_queue_item
    at soup-session.c line 1941
  • #13 soup_session_real_send_message
    at soup-session.c line 2190
  • #14 soup_session_send_message
    at soup-session.c line 2226
  • #15 thread_fn
  • #16 g_thread_proxy
    at gthread.c line 764
  • #17 start_thread
    from /usr/lib/libpthread.so.0
  • #18 clone
    from /usr/lib/libc.so.6

Thread 1 (Thread 0x7ffff7fc7700 (LWP 3589))

  • #0 g_logv
    at gmessages.c line 1038
  • #1 g_log
    at gmessages.c line 1071
  • #2 g_warn_message
    at gmessages.c line 1104
  • #3 soup_session_process_queue_item
    at soup-session.c line 2009
  • #4 async_run_queue
    at soup-session.c line 2039
  • #5 idle_run_queue
    at soup-session.c line 2073
  • #6 g_main_dispatch
    at gmain.c line 3064
  • #7 g_main_context_dispatch
    at gmain.c line 3663
  • #8 g_main_context_iterate
    at gmain.c line 3734
  • #9 g_main_loop_run
    at gmain.c line 3928
  • #10 main

Comment 3 Ross Lagerwall 2014-07-08 22:24:13 UTC
Created attachment 280197 [details]
program to reproduce the problem
Comment 4 Dan Winship 2014-07-18 16:51:05 UTC
Comment on attachment 280196 [details] [review]
soup-session: Only process async items from async_run_queue

yes, this looks right
Comment 5 Ross Lagerwall 2014-07-19 15:28:02 UTC
Comment on attachment 280196 [details] [review]
soup-session: Only process async items from async_run_queue

Pushed to master as d0cbd4a11f1d5968db4856dbc0d97496b3cb0d6b. Thanks for the review!