Title: [226355] trunk
Revision
226355
Author
[email protected]
Date
2018-01-03 00:23:29 -0800 (Wed, 03 Jan 2018)

Log Message

[GTK] Crash destroying WebCore::FileMonitor
https://bugs.webkit.org/show_bug.cgi?id=181138

Reviewed by Michael Catanzaro.

Source/WebCore:

Ensure that platform file monitor is always created and destroyed in the work queue thread synchronously.

* platform/FileMonitor.h:
* platform/glib/FileMonitorGLib.cpp:
(WebCore::FileMonitor::FileMonitor):
(WebCore::FileMonitor::~FileMonitor):
(WebCore::FileMonitor::didChange):

LayoutTests:

Remove test expectations associated to this bug.

* platform/gtk/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (226354 => 226355)


--- trunk/LayoutTests/ChangeLog	2018-01-03 08:18:13 UTC (rev 226354)
+++ trunk/LayoutTests/ChangeLog	2018-01-03 08:23:29 UTC (rev 226355)
@@ -1,3 +1,14 @@
+2018-01-03  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Crash destroying WebCore::FileMonitor
+        https://bugs.webkit.org/show_bug.cgi?id=181138
+
+        Reviewed by Michael Catanzaro.
+
+        Remove test expectations associated to this bug.
+
+        * platform/gtk/TestExpectations:
+
 2018-01-02  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Slow open time enumerating system fonts (FontCache::systemFontFamilies)

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (226354 => 226355)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2018-01-03 08:18:13 UTC (rev 226354)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2018-01-03 08:23:29 UTC (rev 226355)
@@ -1318,13 +1318,6 @@
 
 webkit.org/b/180803 http/tests/media/hls/video-cookie.html [ Crash ]
 
-webkit.org/b/181138 fast/scrolling/rtl-scrollbars-animation-property.html [ Crash Failure ]
-webkit.org/b/181138 intersection-observer/intersection-observer-entry-interface.html [ Crash Pass ]
-webkit.org/b/181138 fast/html/menuitem-element.html [ Pass Crash ]
-webkit.org/b/181138 fast/attachment/attachment-action.html [ Pass Crash ]
-webkit.org/b/181138 fast/canvas/2d.currentPoint.html [ Pass Crash ]
-webkit.org/b/181138 fast/text/international/system-language/arabic-glyph-cache-fill-combine.html [ Pass Crash ]
-
 #////////////////////////////////////////////////////////////////////////////////////////
 # End of Crashing tests
 #////////////////////////////////////////////////////////////////////////////////////////

Modified: trunk/Source/WebCore/ChangeLog (226354 => 226355)


--- trunk/Source/WebCore/ChangeLog	2018-01-03 08:18:13 UTC (rev 226354)
+++ trunk/Source/WebCore/ChangeLog	2018-01-03 08:23:29 UTC (rev 226355)
@@ -1,3 +1,18 @@
+2018-01-03  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Crash destroying WebCore::FileMonitor
+        https://bugs.webkit.org/show_bug.cgi?id=181138
+
+        Reviewed by Michael Catanzaro.
+
+        Ensure that platform file monitor is always created and destroyed in the work queue thread synchronously.
+
+        * platform/FileMonitor.h:
+        * platform/glib/FileMonitorGLib.cpp:
+        (WebCore::FileMonitor::FileMonitor):
+        (WebCore::FileMonitor::~FileMonitor):
+        (WebCore::FileMonitor::didChange):
+
 2018-01-02  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Slow open time enumerating system fonts (FontCache::systemFontFamilies)

Modified: trunk/Source/WebCore/platform/FileMonitor.h (226354 => 226355)


--- trunk/Source/WebCore/platform/FileMonitor.h	2018-01-03 08:18:13 UTC (rev 226354)
+++ trunk/Source/WebCore/platform/FileMonitor.h	2018-01-03 08:23:29 UTC (rev 226355)
@@ -61,7 +61,6 @@
     Ref<WorkQueue> m_handlerQueue;
     Function<void(FileChangeType)> m_modificationHandler;
     GRefPtr<GFileMonitor> m_platformMonitor;
-    GRefPtr<GCancellable> m_cancellable;
 #endif
 };
 

Modified: trunk/Source/WebCore/platform/glib/FileMonitorGLib.cpp (226354 => 226355)


--- trunk/Source/WebCore/platform/glib/FileMonitorGLib.cpp	2018-01-03 08:18:13 UTC (rev 226354)
+++ trunk/Source/WebCore/platform/glib/FileMonitorGLib.cpp	2018-01-03 08:23:29 UTC (rev 226355)
@@ -28,6 +28,7 @@
 
 #include "FileSystem.h"
 #include <wtf/glib/GUniquePtr.h>
+#include <wtf/threads/BinarySemaphore.h>
 
 namespace WebCore {
 
@@ -38,24 +39,32 @@
     if (path.isEmpty() || !m_modificationHandler)
         return;
 
-    m_cancellable = adoptGRef(g_cancellable_new());
-    m_handlerQueue->dispatch([this, cancellable = m_cancellable, path = path.isolatedCopy()] {
-        if (g_cancellable_is_cancelled(cancellable.get()))
-            return;
+    BinarySemaphore semaphore;
+    m_handlerQueue->dispatch([&] {
         auto file = adoptGRef(g_file_new_for_path(FileSystem::fileSystemRepresentation(path).data()));
         GUniqueOutPtr<GError> error;
-        m_platformMonitor = adoptGRef(g_file_monitor(file.get(), G_FILE_MONITOR_NONE, m_cancellable.get(), &error.outPtr()));
-        if (!m_platformMonitor) {
+        m_platformMonitor = adoptGRef(g_file_monitor(file.get(), G_FILE_MONITOR_NONE, nullptr, &error.outPtr()));
+        if (m_platformMonitor)
+            g_signal_connect(m_platformMonitor.get(), "changed", G_CALLBACK(fileChangedCallback), this);
+        else
             WTFLogAlways("Failed to create a monitor for path %s: %s", path.utf8().data(), error->message);
-            return;
-        }
-        g_signal_connect(m_platformMonitor.get(), "changed", G_CALLBACK(fileChangedCallback), this);
+        semaphore.signal();
     });
+    semaphore.wait(WallTime::infinity());
 }
 
 FileMonitor::~FileMonitor()
 {
-    g_cancellable_cancel(m_cancellable.get());
+    // The monitor can be destroyed in the work queue thread.
+    if (&m_handlerQueue->runLoop() == &RunLoop::current())
+        return;
+
+    BinarySemaphore semaphore;
+    m_handlerQueue->dispatch([&] {
+        m_platformMonitor = nullptr;
+        semaphore.signal();
+    });
+    semaphore.wait(WallTime::infinity());
 }
 
 void FileMonitor::fileChangedCallback(GFileMonitor*, GFile*, GFile*, GFileMonitorEvent event, FileMonitor* monitor)
@@ -76,14 +85,9 @@
 void FileMonitor::didChange(FileChangeType type)
 {
     ASSERT(!isMainThread());
-    if (g_cancellable_is_cancelled(m_cancellable.get())) {
+    if (type == FileChangeType::Removal)
         m_platformMonitor = nullptr;
-        return;
-    }
-
     m_modificationHandler(type);
-    if (type == FileChangeType::Removal)
-        m_platformMonitor = nullptr;
 }
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to