GNOME Bugzilla – Bug 749884
GFilemonitor crash: emit_cb can be called on already disposed monitor
Last modified: 2017-10-05 13:04:56 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.
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!