IsoHeapImpl::scavenge* needs to grab the lock
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2018 04:57:43 +0000 (04:57 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2018 04:57:43 +0000 (04:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184461

Reviewed by Filip Pizlo.

Another thread could be modifying the linked list that the scavenge* methods traverse.

* bmalloc/IsoHeapImplInlines.h:
(bmalloc::IsoHeapImpl<Config>::scavenge):
(bmalloc::IsoHeapImpl<Config>::scavengeToHighWatermark):

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

Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc/IsoHeapImplInlines.h

index 03970c9..4aa08e0 100644 (file)
@@ -1,5 +1,18 @@
 2018-04-10  Saam Barati  <sbarati@apple.com>
 
+        IsoHeapImpl::scavenge* needs to grab the lock
+        https://bugs.webkit.org/show_bug.cgi?id=184461
+
+        Reviewed by Filip Pizlo.
+
+        Another thread could be modifying the linked list that the scavenge* methods traverse.
+
+        * bmalloc/IsoHeapImplInlines.h:
+        (bmalloc::IsoHeapImpl<Config>::scavenge):
+        (bmalloc::IsoHeapImpl<Config>::scavengeToHighWatermark):
+
+2018-04-10  Saam Barati  <sbarati@apple.com>
+
         bmalloc should do partial scavenges more frequently
         https://bugs.webkit.org/show_bug.cgi?id=184176
 
index 987ceb5..ed7e36f 100644 (file)
@@ -101,6 +101,7 @@ void IsoHeapImpl<Config>::didBecomeEligible(IsoDirectory<Config, IsoDirectoryPag
 template<typename Config>
 void IsoHeapImpl<Config>::scavenge(Vector<DeferredDecommit>& decommits)
 {
+    std::lock_guard<Mutex> locker(this->lock);
     forEachDirectory(
         [&] (auto& directory) {
             directory.scavenge(decommits);
@@ -111,6 +112,7 @@ void IsoHeapImpl<Config>::scavenge(Vector<DeferredDecommit>& decommits)
 template<typename Config>
 void IsoHeapImpl<Config>::scavengeToHighWatermark(Vector<DeferredDecommit>& decommits)
 {
+    std::lock_guard<Mutex> locker(this->lock);
     if (!m_directoryHighWatermark)
         m_inlineDirectory.scavengeToHighWatermark(decommits);
     for (IsoDirectoryPage<Config>* page = m_headDirectory; page; page = page->next) {