Bug 1231224 part 1 - Fix ExecutableAllocator to not leak a pool when append() OOMs. r=nbp
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 10 Dec 2015 13:22:14 -0500
changeset 310254 89a198f044bfb22a62ed4b88ee72a009ab9a950f
parent 310253 6d8e9838e3665e8e5a3c39cbe73d88617db736a1
child 310255 a80b9fd6fd19262905118d3d3d839f7d2c499b45
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1231224
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1231224 part 1 - Fix ExecutableAllocator to not leak a pool when append() OOMs. r=nbp
js/src/jit/ExecutableAllocator.h
--- a/js/src/jit/ExecutableAllocator.h
+++ b/js/src/jit/ExecutableAllocator.h
@@ -349,19 +349,20 @@ class ExecutableAllocator
 
         // Create a new allocator
         ExecutablePool* pool = createPool(largeAllocSize);
         if (!pool)
             return nullptr;
         // At this point, local |pool| is the owner.
 
         if (m_smallPools.length() < maxSmallPools) {
-            // We haven't hit the maximum number of live pools;  add the new pool.
-            m_smallPools.append(pool);
-            pool->addRef();
+            // We haven't hit the maximum number of live pools; add the new pool.
+            // If append() OOMs, we just return an unshared allocator.
+            if (m_smallPools.append(pool))
+                pool->addRef();
         } else {
             // Find the pool with the least space.
             int iMin = 0;
             for (size_t i = 1; i < m_smallPools.length(); i++) {
                 if (m_smallPools[i]->available() <
                     m_smallPools[iMin]->available())
                 {
                     iMin = i;