REGRESSION(r197543): Use-after-free on storage/indexeddb/transaction-abort-private...
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Mar 2016 00:19:47 +0000 (00:19 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Mar 2016 00:19:47 +0000 (00:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155067

Reviewed by Filip Pizlo.

GCIncommingRefCountedSets need to be finalized before we start
destructing members of the Heap object. Previously, we would
clear all our ArrayBuffer objects when the GCIncommingRefCountedSet
holding them was destroyed. However, ArrayBuffers have a weak
reference to their wrappers. When we would attempt to destroy the
ArrayBuffer object we would end up accessing the WeakImpl for
the weak reference, which had already been freed as we destroyed
our weak block. The solution to this is to move the old
GCIncommingRefCountedSet destructor functionality to a new
function lastChanceToFinalize. This function is called when
we finalize our other objects on Heap destruction.

* heap/GCIncomingRefCountedSet.h:
* heap/GCIncomingRefCountedSetInlines.h:
(JSC::GCIncomingRefCountedSet<T>::lastChanceToFinalize):
(JSC::GCIncomingRefCountedSet<T>::~GCIncomingRefCountedSet): Deleted.
* heap/Heap.cpp:
(JSC::Heap::lastChanceToFinalize):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198565 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/GCIncomingRefCountedSet.h
Source/JavaScriptCore/heap/GCIncomingRefCountedSetInlines.h
Source/JavaScriptCore/heap/Heap.cpp

index 8b99f44..6f065d4 100644 (file)
@@ -1,3 +1,29 @@
+2016-03-22  Keith Miller  <keith_miller@apple.com>
+
+        REGRESSION(r197543): Use-after-free on storage/indexeddb/transaction-abort-private.html
+        https://bugs.webkit.org/show_bug.cgi?id=155067
+
+        Reviewed by Filip Pizlo.
+
+        GCIncommingRefCountedSets need to be finalized before we start
+        destructing members of the Heap object. Previously, we would
+        clear all our ArrayBuffer objects when the GCIncommingRefCountedSet
+        holding them was destroyed. However, ArrayBuffers have a weak
+        reference to their wrappers. When we would attempt to destroy the
+        ArrayBuffer object we would end up accessing the WeakImpl for
+        the weak reference, which had already been freed as we destroyed
+        our weak block. The solution to this is to move the old
+        GCIncommingRefCountedSet destructor functionality to a new
+        function lastChanceToFinalize. This function is called when
+        we finalize our other objects on Heap destruction.
+
+        * heap/GCIncomingRefCountedSet.h:
+        * heap/GCIncomingRefCountedSetInlines.h:
+        (JSC::GCIncomingRefCountedSet<T>::lastChanceToFinalize):
+        (JSC::GCIncomingRefCountedSet<T>::~GCIncomingRefCountedSet): Deleted.
+        * heap/Heap.cpp:
+        (JSC::Heap::lastChanceToFinalize):
+
 2016-03-22  Per Arne Vollan  <peavo@outlook.com>
 
         [Win] [64-bit] Remove MSVC 2013 FMA3 Bug Workaround
index 5e7254a..a3155a2 100644 (file)
@@ -36,8 +36,9 @@ template<typename T>
 class GCIncomingRefCountedSet {
 public:
     GCIncomingRefCountedSet();
-    ~GCIncomingRefCountedSet();
-    
+
+    void lastChanceToFinalize();
+
     // Returns true if the native object is new to this set.
     bool addReference(JSCell*, T*);
     
index 52c55e2..a4f1045 100644 (file)
@@ -38,7 +38,7 @@ GCIncomingRefCountedSet<T>::GCIncomingRefCountedSet()
 }
 
 template<typename T>
-GCIncomingRefCountedSet<T>::~GCIncomingRefCountedSet()
+void GCIncomingRefCountedSet<T>::lastChanceToFinalize()
 {
     for (size_t i = m_vector.size(); i--;)
         m_vector[i]->filterIncomingReferences(removeAll);
index a0dcd8d..bf3ece3 100644 (file)
@@ -382,6 +382,7 @@ void Heap::lastChanceToFinalize()
     RELEASE_ASSERT(!m_vm->entryScope);
     RELEASE_ASSERT(m_operationInProgress == NoOperation);
 
+    m_arrayBuffers.lastChanceToFinalize();
     m_codeBlocks.lastChanceToFinalize();
     m_objectSpace.lastChanceToFinalize();
     releaseDelayedReleasedObjects();