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 775514 - Aborts on g_mutex_clear when force unmounting
Aborts on g_mutex_clear when force unmounting
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: afc backend and volume monitor
1.29.x
Other Linux
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2016-12-02 11:41 UTC by Ondrej Holy
Modified: 2017-08-15 06:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
afc: Leak mutex when force unmounting (1.00 KB, patch)
2016-12-02 11:44 UTC, Ondrej Holy
none Details | Review
afc: Leak mutex when force unmounting (1017 bytes, patch)
2016-12-06 16:59 UTC, Ondrej Holy
committed Details | Review

Description Ondrej Holy 2016-12-02 11:41:25 UTC
The afc daemon sometimes aborts on g_mutex_clear when force unmounting. I suppose that the mutex is locked and thus it aborts. However, I wonder why it can be locked, because it seems to me that we operate with the mutex only on the main thread... 

Backtrace:
1 __GI_raise
2 __GI_abort
3 g_mutex_clear
4 g_vfs_backend_afc_close_connection
5 force_umount_idle
6 g_idle_dispatch
7 g_main_context_dispatch
8 g_main_context_iterate
9 g_main_loop_run
10 daemon_main
11 main 

Source:
https://retrace.fedoraproject.org/faf/problems/?component_names=gvfs&function_names=g_vfs_backend_afc_close_connection
Comment 1 Ondrej Holy 2016-12-02 11:43:44 UTC
Hadess, can you please try reproducing it and provide full backtrace?
Comment 2 Ondrej Holy 2016-12-02 11:44:30 UTC
Created attachment 341234 [details] [review]
afc: Leak mutex when force unmounting

The afc daemon sometimes aborts on g_mutex_clear when force unmounting.
Leak the mutex in order to avoid the aborts. The daemon will hopefully
finish successfully then...
Comment 3 Ondrej Holy 2016-12-06 16:59:30 UTC
Created attachment 341497 [details] [review]
afc: Leak mutex when force unmounting
Comment 4 Bastien Nocera 2016-12-07 13:06:51 UTC
(In reply to Ondrej Holy from comment #0)
> The afc daemon sometimes aborts on g_mutex_clear when force unmounting. I
> suppose that the mutex is locked and thus it aborts. However, I wonder why
> it can be locked, because it seems to me that we operate with the mutex only
> on the main thread... 

There doesn't seem to be a reproducer for this, or a bugzilla report which would show the backtrace for every thread, if there is indeed another one.

So the only possibility I see is something having already freed the mutex, or the structure it's in, possibly us.

Let me try to reproduce.
Comment 5 Bastien Nocera 2016-12-07 17:41:47 UTC
I don't know how to reproduce the problem I'm afraid. Code analysis also didn't bring up anything obvious.
Comment 6 Bastien Nocera 2016-12-08 15:05:01 UTC
This will only happen when unplugging the device, not when umounting it cleanly, otherwise it wouldn't go through force_umount_idle(). Maybe a race between unmounting and unplugging? Seems unlikely.
Comment 7 Ondrej Holy 2016-12-09 15:55:15 UTC
Hmm, I though that the backend uses try_ methods initially, but it isn't, so force_unmount_idle is actually a different thread, because jobs are running on the thread pool... so the mutex can be actually locked, because some other job can be still running... so if we use the proposed patch and have some luck, it may finish the unmount properly...
Comment 8 Bastien Nocera 2017-08-12 13:21:54 UTC
Review of attachment 341497 [details] [review]:

Based on comment 7, let's commit this.
Comment 9 Ondrej Holy 2017-08-15 06:50:12 UTC
Attachment 341497 [details] pushed as c110200 - afc: Leak mutex when force unmounting