Title: [260067] trunk/Source/WebCore
- Revision
- 260067
- Author
- [email protected]
- Date
- 2020-04-14 03:24:51 -0700 (Tue, 14 Apr 2020)
Log Message
[GLIB] Fix race condition in FileMonitor implementation
https://bugs.webkit.org/show_bug.cgi?id=210483
Reviewed by Adrian Perez de Castro.
This is causing flaky timeouts when running resource load statistics layout tests. The problem is that we assume
FileMonitor has the last reference of the platform monitor and it's deleted on g_object_unref(), but GLib keeps
another reference that is released later on a different thread if the monitor is still active. We just need to
ensure we cancel the monitor before calling g_object_unref().
* platform/FileMonitor.h:
* platform/glib/FileMonitorGLib.cpp:
(WebCore::FileMonitor::~FileMonitor):
(WebCore::FileMonitor::didChange):
(WebCore::FileMonitor::cancel):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (260066 => 260067)
--- trunk/Source/WebCore/ChangeLog 2020-04-14 09:58:50 UTC (rev 260066)
+++ trunk/Source/WebCore/ChangeLog 2020-04-14 10:24:51 UTC (rev 260067)
@@ -1,3 +1,21 @@
+2020-04-14 Carlos Garcia Campos <[email protected]>
+
+ [GLIB] Fix race condition in FileMonitor implementation
+ https://bugs.webkit.org/show_bug.cgi?id=210483
+
+ Reviewed by Adrian Perez de Castro.
+
+ This is causing flaky timeouts when running resource load statistics layout tests. The problem is that we assume
+ FileMonitor has the last reference of the platform monitor and it's deleted on g_object_unref(), but GLib keeps
+ another reference that is released later on a different thread if the monitor is still active. We just need to
+ ensure we cancel the monitor before calling g_object_unref().
+
+ * platform/FileMonitor.h:
+ * platform/glib/FileMonitorGLib.cpp:
+ (WebCore::FileMonitor::~FileMonitor):
+ (WebCore::FileMonitor::didChange):
+ (WebCore::FileMonitor::cancel):
+
2020-04-14 Charlie Turner <[email protected]>
[EME][CDMProxy] Fix waitingForKey logic
Modified: trunk/Source/WebCore/platform/FileMonitor.h (260066 => 260067)
--- trunk/Source/WebCore/platform/FileMonitor.h 2020-04-14 09:58:50 UTC (rev 260066)
+++ trunk/Source/WebCore/platform/FileMonitor.h 2020-04-14 10:24:51 UTC (rev 260067)
@@ -56,6 +56,7 @@
#if USE(GLIB)
static void fileChangedCallback(GFileMonitor*, GFile*, GFile*, GFileMonitorEvent, FileMonitor*);
void didChange(FileChangeType);
+ void cancel();
Ref<WorkQueue> m_handlerQueue;
Function<void(FileChangeType)> m_modificationHandler;
GRefPtr<GFileMonitor> m_platformMonitor;
Modified: trunk/Source/WebCore/platform/glib/FileMonitorGLib.cpp (260066 => 260067)
--- trunk/Source/WebCore/platform/glib/FileMonitorGLib.cpp 2020-04-14 09:58:50 UTC (rev 260066)
+++ trunk/Source/WebCore/platform/glib/FileMonitorGLib.cpp 2020-04-14 10:24:51 UTC (rev 260067)
@@ -66,12 +66,14 @@
FileMonitor::~FileMonitor()
{
// The monitor can be destroyed in the work queue thread.
- if (&m_handlerQueue->runLoop() == &RunLoop::current())
+ if (&m_handlerQueue->runLoop() == &RunLoop::current()) {
+ cancel();
return;
+ }
BinarySemaphore semaphore;
m_handlerQueue->dispatch([&] {
- m_platformMonitor = nullptr;
+ cancel();
semaphore.signal();
});
semaphore.wait();
@@ -96,8 +98,17 @@
{
ASSERT(!isMainThread());
if (type == FileChangeType::Removal)
- m_platformMonitor = nullptr;
+ cancel();
m_modificationHandler(type);
}
+void FileMonitor::cancel()
+{
+ if (!m_platformMonitor)
+ return;
+
+ g_file_monitor_cancel(m_platformMonitor.get());
+ m_platformMonitor = nullptr;
+}
+
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes