[glib/glib-2-68: 1/2] glocalfilemonitor: Avoid a deadlock on finalization
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-68: 1/2] glocalfilemonitor: Avoid a deadlock on finalization
- Date: Tue, 15 Jun 2021 18:40:12 +0000 (UTC)
commit f49710b8aadc78043e8001f980ab6b93c4dcc2b0
Author: Philip Withnall <pwithnall endlessos org>
Date: Mon Jun 14 15:02:59 2021 +0100
glocalfilemonitor: Avoid a deadlock on finalization
If `g_file_monitor_source_dispatch()` drops the last reference to its
`GLocalFileMonitor`, a deadlock will occur, because disposing the
`GLocalFileMonitor` causes synchronous disposal of the
`GFileMonitorSource`, and hence an attempt to re-lock the already-locked
mutex in the `GFileMonitorSource`.
Fix that by dropping the reference to the `GLocalFileMonitor` after
unlocking.
Diagnosed by Ting-Wei Lan. The bug was originally introduced by me in
commit 592a13b483.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
gio/glocalfilemonitor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c
index eccab231c..dc32fb660 100644
--- a/gio/glocalfilemonitor.c
+++ b/gio/glocalfilemonitor.c
@@ -555,8 +555,8 @@ g_file_monitor_source_dispatch (GSource *source,
g_file_monitor_source_update_ready_time (fms);
- g_clear_object (&instance);
g_mutex_unlock (&fms->lock);
+ g_clear_object (&instance);
/* We now have our list of events to deliver */
while ((event = g_queue_pop_head (&event_queue)))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]