Title: [215694] trunk/Source/_javascript_Core
Revision
215694
Author
sbar...@apple.com
Date
2017-04-24 14:11:44 -0700 (Mon, 24 Apr 2017)

Log Message

ASSERTION FAILED: m_table seen with workers/wasm-hashset LayoutTests
https://bugs.webkit.org/show_bug.cgi?id=171119
<rdar://problem/31760635>

Reviewed by Keith Miller.

The HashSet of timer set notification callbacks can be accessed
and augmented simultaneously from different threads. e.g, the worker
thread can augment it while the wasm compilation thread will
access it. Therefore, accesses must be guarded by a lock.

* runtime/JSRunLoopTimer.cpp:
(JSC::JSRunLoopTimer::scheduleTimer):
(JSC::JSRunLoopTimer::addTimerSetNotification):
(JSC::JSRunLoopTimer::removeTimerSetNotification):
* runtime/JSRunLoopTimer.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (215693 => 215694)


--- trunk/Source/_javascript_Core/ChangeLog	2017-04-24 20:58:26 UTC (rev 215693)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-04-24 21:11:44 UTC (rev 215694)
@@ -1,3 +1,22 @@
+2017-04-24  Saam Barati  <sbar...@apple.com>
+
+        ASSERTION FAILED: m_table seen with workers/wasm-hashset LayoutTests
+        https://bugs.webkit.org/show_bug.cgi?id=171119
+        <rdar://problem/31760635>
+
+        Reviewed by Keith Miller.
+
+        The HashSet of timer set notification callbacks can be accessed
+        and augmented simultaneously from different threads. e.g, the worker
+        thread can augment it while the wasm compilation thread will
+        access it. Therefore, accesses must be guarded by a lock.
+
+        * runtime/JSRunLoopTimer.cpp:
+        (JSC::JSRunLoopTimer::scheduleTimer):
+        (JSC::JSRunLoopTimer::addTimerSetNotification):
+        (JSC::JSRunLoopTimer::removeTimerSetNotification):
+        * runtime/JSRunLoopTimer.h:
+
 2017-04-24  Joseph Pecoraro  <pecor...@apple.com>
 
         test262: test262/test/language/computed-property-names/class/static/getter-prototype.js

Modified: trunk/Source/_javascript_Core/runtime/JSRunLoopTimer.cpp (215693 => 215694)


--- trunk/Source/_javascript_Core/runtime/JSRunLoopTimer.cpp	2017-04-24 20:58:26 UTC (rev 215693)
+++ trunk/Source/_javascript_Core/runtime/JSRunLoopTimer.cpp	2017-04-24 21:11:44 UTC (rev 215694)
@@ -104,6 +104,7 @@
 {
     CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + intervalInSeconds.seconds());
     m_isScheduled = true;
+    auto locker = holdLock(m_timerCallbacksLock);
     for (auto& task : m_timerSetCallbacks)
         task->run();
 }
@@ -142,6 +143,8 @@
 {
     m_timer.startOneShot(intervalInSeconds);
     m_isScheduled = true;
+
+    auto locker = holdLock(m_timerCallbacksLock);
     for (auto& task : m_timerSetCallbacks)
         task->run();
 }
@@ -156,11 +159,13 @@
 
 void JSRunLoopTimer::addTimerSetNotification(TimerNotificationCallback callback)
 {
+    auto locker = holdLock(m_timerCallbacksLock);
     m_timerSetCallbacks.add(callback);
 }
 
 void JSRunLoopTimer::removeTimerSetNotification(TimerNotificationCallback callback)
 {
+    auto locker = holdLock(m_timerCallbacksLock);
     m_timerSetCallbacks.remove(callback);
 }
 

Modified: trunk/Source/_javascript_Core/runtime/JSRunLoopTimer.h (215693 => 215694)


--- trunk/Source/_javascript_Core/runtime/JSRunLoopTimer.h	2017-04-24 20:58:26 UTC (rev 215693)
+++ trunk/Source/_javascript_Core/runtime/JSRunLoopTimer.h	2017-04-24 21:11:44 UTC (rev 215694)
@@ -62,6 +62,10 @@
     void cancelTimer();
     bool isScheduled() const { return m_isScheduled; }
 
+    // Note: The only thing the timer notification callback cannot do is
+    // call scheduleTimer(). This will cause a deadlock. It would not
+    // be hard to make this work, however, there are no clients that need
+    // this behavior. We should implement it only if we find that we need it.
     JS_EXPORT_PRIVATE void addTimerSetNotification(TimerNotificationCallback);
     JS_EXPORT_PRIVATE void removeTimerSetNotification(TimerNotificationCallback);
 
@@ -87,6 +91,7 @@
     RunLoop::Timer<JSRunLoopTimer> m_timer;
 #endif
 
+    Lock m_timerCallbacksLock;
     HashSet<TimerNotificationCallback> m_timerSetCallbacks;
     
 private:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to