Title: [212442] trunk/Source/_javascript_Core
Revision
212442
Author
[email protected]
Date
2017-02-16 10:07:28 -0800 (Thu, 16 Feb 2017)

Log Message

Weak should not use jsCast in its accessors
https://bugs.webkit.org/show_bug.cgi?id=168406

Reviewed by Filip Pizlo.

This can cause assertion failures in WebCore where classes might remove themselves
from a data structure in a weak reference, if that reference is still alive.

* heap/WeakInlines.h:
(JSC::>):
(JSC::Weak<T>::operator):
(JSC::Weak<T>::get):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (212441 => 212442)


--- trunk/Source/_javascript_Core/ChangeLog	2017-02-16 18:07:17 UTC (rev 212441)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-02-16 18:07:28 UTC (rev 212442)
@@ -1,3 +1,18 @@
+2017-02-15  Keith Miller  <[email protected]>
+
+        Weak should not use jsCast in its accessors
+        https://bugs.webkit.org/show_bug.cgi?id=168406
+
+        Reviewed by Filip Pizlo.
+
+        This can cause assertion failures in WebCore where classes might remove themselves
+        from a data structure in a weak reference, if that reference is still alive.
+
+        * heap/WeakInlines.h:
+        (JSC::>):
+        (JSC::Weak<T>::operator):
+        (JSC::Weak<T>::get):
+
 2017-02-16  Yusuke Suzuki  <[email protected]>
 
         Web Inspector: allow import() inside the inspector

Modified: trunk/Source/_javascript_Core/heap/WeakInlines.h (212441 => 212442)


--- trunk/Source/_javascript_Core/heap/WeakInlines.h	2017-02-16 18:07:17 UTC (rev 212441)
+++ trunk/Source/_javascript_Core/heap/WeakInlines.h	2017-02-16 18:07:28 UTC (rev 212442)
@@ -71,20 +71,23 @@
 template<typename T> inline T* Weak<T>::operator->() const
 {
     ASSERT(m_impl && m_impl->state() == WeakImpl::Live);
-    return jsCast<T*>(m_impl->jsValue().asCell());
+    // We can't use jsCast here since we could be called in a finalizer.
+    return static_cast<T*>(m_impl->jsValue().asCell());
 }
 
 template<typename T> inline T& Weak<T>::operator*() const
 {
     ASSERT(m_impl && m_impl->state() == WeakImpl::Live);
-    return *jsCast<T*>(m_impl->jsValue().asCell());
+    // We can't use jsCast here since we could be called in a finalizer.
+    return *static_cast<T*>(m_impl->jsValue().asCell());
 }
 
 template<typename T> inline T* Weak<T>::get() const
 {
     if (!m_impl || m_impl->state() != WeakImpl::Live)
-        return 0;
-    return jsCast<T*>(m_impl->jsValue().asCell());
+        return nullptr;
+    // We can't use jsCast here since we could be called in a finalizer.
+    return static_cast<T*>(m_impl->jsValue().asCell());
 }
 
 template<typename T> inline bool Weak<T>::was(T* other) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to