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 749884 - GFilemonitor crash: emit_cb can be called on already disposed monitor
GFilemonitor crash: emit_cb can be called on already disposed monitor
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gio
2.44.x
Other opensolaris
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-05-26 10:10 UTC by Alexander Pyhalov
Modified: 2017-10-05 13:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch which reduces race probability (424 bytes, patch)
2015-05-26 10:10 UTC, Alexander Pyhalov
rejected Details | Review

Description Alexander Pyhalov 2015-05-26 10:10:22 UTC
Created attachment 303986 [details] [review]
patch which reduces race probability

I see the following behavior in thunderbird (on Save As dialog). Sometimes the same crash can occur in nautilus. Unfortunately I couldn't reproduce the crash in some synthetic example. 

1) file monitor is being disposed,   
2) emit_in_idle is called
3) signal is registered and emit_cb is called
4) when emit_cb is called, monitor is already disposed and application crashes on the first line of emit_cb (GFileMonitor *monitor = G_FILE_MONITOR (data) ). 

It seems that checking for priv->cancelled in emit_in_idle fixes this particular issue at least in thunderbird.  But I'm not sure that it's enough as when g_file_monitor_dispose() and emit_in_idle() are called in parallel
g_file_monitor_dispose() can clean priv->pending_file_change_source and not call g_file_monitor_cancel() yet. In this case emit_in_idle() can not detect that monitor is being disposed and still register emit_cb() callback.
Comment 1 Philip Withnall 2017-10-05 13:04:38 UTC
Review of attachment 303986 [details] [review]:

Thanks for the patch. However, this code was significantly reworked in commit 2737ab3201163631be152801a859b3874a667f10 (and others), so the code your patch touches no longer exists in any form, and hence the race is likely to have been eliminated. If you find there’s still a problem with the new code, please file a new bug report. Thanks!