GNOME Bugzilla – Bug 732783
Segfault with concurrent async and sync operations
Last modified: 2014-07-19 16:19:31 UTC
Created attachment 279964 [details] crash reproducer Since gvfs was ported to use a single SoupSession for sync and async operations, I discovered that the dav backend segfaulted sometimes. I managed to track it down to libsoup with the attached program. Doing repeated concurrent sync and async operations in separate threads causes libsoup to segfault reliably. Example backtrace:
+ Trace 233775
Thread 2 (Thread 0x7ffff56a3700 (LWP 28686))
Thread 1 (Thread 0x7ffff7fc7700 (LWP 28682))
Maybe an item in the queue has become corrupted due to concurrent access? Thanks.
I found that the webdav backend was segfaulting when displaying a location in Nautilus. It was due to query info calls (which do synchronous libsoup calls) running in parallel with thumbnail generation (which reads the file which in turn does asynchronous libsoup calls).
Created attachment 279980 [details] [review] soup-message-queue: Hold mutex when ref'ing Protect access to ref_count with the queue mutex when incrementing the reference count.
The above patch seems to fix the issue. As an aside, if the sync API is used from one thread and the async API from another thread, is it necessary for both threads to have different thread-default main contexts?
Comment on attachment 279980 [details] [review] soup-message-queue: Hold mutex when ref'ing ok, though we should probably make it use atomic ops instead at some point...
(In reply to comment #4) > (From update of attachment 279980 [details] [review]) > ok, though we should probably make it use atomic ops instead at some point... Maybe. As far as I can see, the other uses of ref_count are protected by the queue mutex anyway so an atomic counter is probably unnecessary.
Comment on attachment 279980 [details] [review] soup-message-queue: Hold mutex when ref'ing Pushed to master as 053fdb041cded88c396c98e525212819fa5fce01. Thanks for the review!
(In reply to comment #5) > Maybe. As far as I can see, the other uses of ref_count are protected by the > queue mutex anyway so an atomic counter is probably unnecessary. yeah, but it would probably be faster than using a mutex