Don't crash in forEachEntry when DebugHeap is enabled.
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Nov 2017 18:24:56 +0000 (18:24 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 27 Nov 2017 18:24:56 +0000 (18:24 +0000)
Unreviewed, fixing crashes on leaks bots by removing an assertion.

* bmalloc/IsoTLS.cpp:
(bmalloc::IsoTLS::forEachEntry):
* test/testbmalloc.cpp: Make this test work with DebugHeap so I can catch this kind of problem in the future.

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

Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc/IsoTLS.cpp
Source/bmalloc/test/testbmalloc.cpp

index e4866a9..2773b5c 100644 (file)
@@ -1,3 +1,13 @@
+2017-11-27  Filip Pizlo  <fpizlo@apple.com>
+
+        Don't crash in forEachEntry when DebugHeap is enabled.
+
+        Unreviewed, fixing crashes on leaks bots by removing an assertion.
+
+        * bmalloc/IsoTLS.cpp:
+        (bmalloc::IsoTLS::forEachEntry):
+        * test/testbmalloc.cpp: Make this test work with DebugHeap so I can catch this kind of problem in the future.
+
 2017-11-16  Filip Pizlo  <fpizlo@apple.com>
 
         Isolated Heaps caused an increase in reported leaks on the bots
index 041f4ba..ec3fcab 100644 (file)
@@ -167,7 +167,8 @@ size_t IsoTLS::size()
 template<typename Func>
 void IsoTLS::forEachEntry(const Func& func)
 {
-    RELEASE_BASSERT(m_lastEntry);
+    if (!m_lastEntry)
+        return;
     PerProcess<IsoTLSLayout>::get()->head()->walkUpToInclusive(
         m_lastEntry,
         [&] (IsoTLSEntry* entry) {
index c3b7ab4..d71dc1b 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include <bmalloc/bmalloc.h>
+#include <bmalloc/Environment.h>
 #include <bmalloc/IsoHeapInlines.h>
 #include <cmath>
 #include <cstdlib>
@@ -72,6 +73,10 @@ static std::set<void*> toptrset(const std::vector<void*>& ptrs)
 
 static void assertEmptyPointerSet(const std::set<void*>& pointers)
 {
+    if (PerProcess<Environment>::get()->isDebugHeapEnabled()) {
+        printf("    skipping checks because DebugHeap.\n");
+        return;
+    }
     if (pointers.empty())
         return;
     printf("Pointer set not empty!\n");
@@ -85,6 +90,10 @@ static void assertEmptyPointerSet(const std::set<void*>& pointers)
 template<typename heapType>
 static void assertHasObjects(IsoHeap<heapType>& heap, std::set<void*> pointers)
 {
+    if (PerProcess<Environment>::get()->isDebugHeapEnabled()) {
+        printf("    skipping checks because DebugHeap.\n");
+        return;
+    }
     auto& impl = heap.impl();
     std::lock_guard<Mutex> locker(impl.lock);
     impl.forEachLiveObject(
@@ -97,6 +106,10 @@ static void assertHasObjects(IsoHeap<heapType>& heap, std::set<void*> pointers)
 template<typename heapType>
 static void assertHasOnlyObjects(IsoHeap<heapType>& heap, std::set<void*> pointers)
 {
+    if (PerProcess<Environment>::get()->isDebugHeapEnabled()) {
+        printf("    skipping checks because DebugHeap.\n");
+        return;
+    }
     auto& impl = heap.impl();
     std::lock_guard<Mutex> locker(impl.lock);
     impl.forEachLiveObject(
@@ -110,13 +123,16 @@ template<typename heapType>
 static void assertClean(IsoHeap<heapType>& heap)
 {
     scavengeThisThread();
-    auto& impl = heap.impl();
-    {
-        std::lock_guard<Mutex> locker(impl.lock);
-        CHECK(!impl.numLiveObjects());
+    if (!PerProcess<Environment>::get()->isDebugHeapEnabled()) {
+        auto& impl = heap.impl();
+        {
+            std::lock_guard<Mutex> locker(impl.lock);
+            CHECK(!impl.numLiveObjects());
+        }
     }
     heap.scavenge();
-    {
+    if (!PerProcess<Environment>::get()->isDebugHeapEnabled()) {
+        auto& impl = heap.impl();
         std::lock_guard<Mutex> locker(impl.lock);
         CHECK(!impl.numCommittedPages());
     }