Diff
Modified: trunk/Source/bmalloc/CMakeLists.txt (198808 => 198809)
--- trunk/Source/bmalloc/CMakeLists.txt 2016-03-29 22:57:01 UTC (rev 198808)
+++ trunk/Source/bmalloc/CMakeLists.txt 2016-03-29 23:19:11 UTC (rev 198809)
@@ -9,6 +9,7 @@
bmalloc/Environment.cpp
bmalloc/FreeList.cpp
bmalloc/Heap.cpp
+ bmalloc/Logging.cpp
bmalloc/ObjectType.cpp
bmalloc/SegregatedFreeList.cpp
bmalloc/StaticMutex.cpp
Modified: trunk/Source/bmalloc/ChangeLog (198808 => 198809)
--- trunk/Source/bmalloc/ChangeLog 2016-03-29 22:57:01 UTC (rev 198808)
+++ trunk/Source/bmalloc/ChangeLog 2016-03-29 23:19:11 UTC (rev 198809)
@@ -1,3 +1,29 @@
+2016-03-29 David Kilzer <ddkil...@apple.com>
+
+ bmalloc: add logging for mmap() failures
+ <http://webkit.org/b/155409>
+ <rdar://problem/24568515>
+
+ Reviewed by Saam Barati.
+
+ This patch causes additional logging to be generated on internal
+ iOS builds when mmap() fails. We are trying to track down an
+ issue where the WebContent process runs out of VM address space
+ before it is killed by jetsam.
+
+ * CMakeLists.txt: Add Logging.cpp.
+ * bmalloc.xcodeproj/project.pbxproj: Add new files.
+
+ * bmalloc/BAssert.h:
+ (RELEASE_BASSERT_WITH_MESSAGE): Add macro.
+ * bmalloc/Logging.cpp: Added.
+ (bmalloc::logVMFailure): Implementation.
+ * bmalloc/Logging.h: Added.
+ (bmalloc::logVMFailure): Declaration.
+ * bmalloc/VMAllocate.h:
+ (bmalloc::tryVMAllocate): Call logVMFailure() on mmap() failure.
+ * bmalloc/darwin/BSoftLinking.h: Copied from Source/WebCore/platform/mac/SoftLinking.h.
+
2016-03-26 Geoffrey Garen <gga...@apple.com>
Unreviewed, rolling out r198702, r198704.
Modified: trunk/Source/bmalloc/bmalloc/BAssert.h (198808 => 198809)
--- trunk/Source/bmalloc/bmalloc/BAssert.h 2016-03-29 22:57:01 UTC (rev 198808)
+++ trunk/Source/bmalloc/bmalloc/BAssert.h 2016-03-29 23:19:11 UTC (rev 198809)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -63,6 +63,9 @@
#define RELEASE_BASSERT(x) BASSERT_IMPL(x)
+// FIXME: Implement logging: <https://webkit.org/b/155992>
+#define RELEASE_BASSERT_WITH_MESSAGE(x, f, ...) BASSERT_IMPL(x)
+
#define UNUSED(x) (void)x
// ===== Release build =====
Added: trunk/Source/bmalloc/bmalloc/Logging.cpp (0 => 198809)
--- trunk/Source/bmalloc/bmalloc/Logging.cpp (rev 0)
+++ trunk/Source/bmalloc/bmalloc/Logging.cpp 2016-03-29 23:19:11 UTC (rev 198809)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "Logging.h"
+#include "BPlatform.h"
+
+#if BPLATFORM(IOS)
+#include <mach/exception_types.h>
+#include <objc/objc.h>
+#include <unistd.h>
+
+#include "BSoftLinking.h"
+BSOFT_LINK_FRAMEWORK(CrashReporterSupport);
+BSOFT_LINK_FUNCTION(CrashReporterSupport, SimulateCrash, BOOL, (pid_t pid, mach_exception_data_type_t exceptionCode, id description), (pid, exceptionCode, description));
+#endif
+
+namespace bmalloc {
+
+void logVMFailure()
+{
+#if BPLATFORM(IOS)
+ const mach_exception_data_type_t kExceptionCode = 0xc105ca11;
+ SimulateCrash(getpid(), kExceptionCode, nullptr);
+#endif
+}
+
+} // namespace bmalloc
Added: trunk/Source/bmalloc/bmalloc/Logging.h (0 => 198809)
--- trunk/Source/bmalloc/bmalloc/Logging.h (rev 0)
+++ trunk/Source/bmalloc/bmalloc/Logging.h 2016-03-29 23:19:11 UTC (rev 198809)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef Logging_h
+#define Logging_h
+
+namespace bmalloc {
+
+void logVMFailure();
+
+} // namespace bmalloc
+
+#endif // Logging_h
Modified: trunk/Source/bmalloc/bmalloc/VMAllocate.h (198808 => 198809)
--- trunk/Source/bmalloc/bmalloc/VMAllocate.h 2016-03-29 22:57:01 UTC (rev 198808)
+++ trunk/Source/bmalloc/bmalloc/VMAllocate.h 2016-03-29 23:19:11 UTC (rev 198809)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,6 +27,7 @@
#define VMAllocate_h
#include "BAssert.h"
+#include "Logging.h"
#include "Range.h"
#include "Sizes.h"
#include "Syscall.h"
@@ -77,8 +78,10 @@
{
vmValidate(vmSize);
void* result = mmap(0, vmSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, BMALLOC_VM_TAG, 0);
- if (result == MAP_FAILED)
+ if (result == MAP_FAILED) {
+ logVMFailure();
return nullptr;
+ }
return result;
}
Added: trunk/Source/bmalloc/bmalloc/darwin/BSoftLinking.h (0 => 198809)
--- trunk/Source/bmalloc/bmalloc/darwin/BSoftLinking.h (rev 0)
+++ trunk/Source/bmalloc/bmalloc/darwin/BSoftLinking.h 2016-03-29 23:19:11 UTC (rev 198809)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2007, 2008, 2011-2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BSoftLinking_h
+#define BSoftLinking_h
+
+#include "BAssert.h"
+#include <dlfcn.h>
+#include <mutex>
+
+#define BSOFT_LINK_FRAMEWORK(framework) \
+ static void* framework##Library() \
+ { \
+ static void* frameworkLibrary; \
+ static std::once_flag once; \
+ std::call_once(once, [] { \
+ frameworkLibrary = dlopen("/System/Library/Frameworks/" #framework ".framework/" #framework, RTLD_NOW); \
+ RELEASE_BASSERT_WITH_MESSAGE(frameworkLibrary, "%s", dlerror()); \
+ }); \
+ return frameworkLibrary; \
+ }
+
+#define BSOFT_LINK_FUNCTION(framework, functionName, resultType, parameterDeclarations, parameterNames) \
+ extern "C" { \
+ resultType functionName parameterDeclarations; \
+ } \
+ static resultType init##functionName parameterDeclarations; \
+ static resultType (*softLink##functionName) parameterDeclarations = init##functionName; \
+ \
+ static resultType init##functionName parameterDeclarations \
+ { \
+ static std::once_flag once; \
+ std::call_once(once, [] { \
+ softLink##functionName = (resultType (*) parameterDeclarations) dlsym(framework##Library(), #functionName); \
+ RELEASE_BASSERT_WITH_MESSAGE(softLink##functionName, "%s", dlerror()); \
+ }); \
+ return softLink##functionName parameterNames; \
+ } \
+ \
+ inline resultType functionName parameterDeclarations \
+ { \
+ return softLink##functionName parameterNames; \
+ }
+
+#endif // BSoftLinking_h
Modified: trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj (198808 => 198809)
--- trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj 2016-03-29 22:57:01 UTC (rev 198808)
+++ trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj 2016-03-29 23:19:11 UTC (rev 198809)
@@ -63,6 +63,9 @@
14F271C718EA3990008C152F /* Heap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14DA320E18875D9F007269E0 /* Heap.cpp */; };
14F271C818EA3990008C152F /* ObjectType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14105E8318E14374003A106E /* ObjectType.cpp */; };
14F271C918EA3990008C152F /* VMHeap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 144F7BFB18BFC517003537F3 /* VMHeap.cpp */; };
+ 4426E2801C838EE0008EB042 /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4426E27E1C838EE0008EB042 /* Logging.cpp */; };
+ 4426E2811C838EE0008EB042 /* Logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 4426E27F1C838EE0008EB042 /* Logging.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 4426E2831C839547008EB042 /* BSoftLinking.h in Headers */ = {isa = PBXBuildFile; fileRef = 4426E2821C839547008EB042 /* BSoftLinking.h */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -137,6 +140,9 @@
14DA320E18875D9F007269E0 /* Heap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Heap.cpp; path = bmalloc/Heap.cpp; sourceTree = "<group>"; };
14EB79E81C7C1BC4005E834F /* XLargeRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLargeRange.h; path = bmalloc/XLargeRange.h; sourceTree = "<group>"; };
14F271BE18EA3963008C152F /* libbmalloc.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libbmalloc.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ 4426E27E1C838EE0008EB042 /* Logging.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Logging.cpp; path = bmalloc/Logging.cpp; sourceTree = "<group>"; };
+ 4426E27F1C838EE0008EB042 /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = bmalloc/Logging.h; sourceTree = "<group>"; };
+ 4426E2821C839547008EB042 /* BSoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSoftLinking.h; path = bmalloc/darwin/BSoftLinking.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -276,6 +282,7 @@
14D9DB4F17F2868900EAAB79 /* stdlib */ = {
isa = PBXGroup;
children = (
+ 4408F2961C9896C40012EC64 /* darwin */,
1421A87718EE462A00B4DD68 /* Algorithm.h */,
1417F65218BA88A00076FA3F /* AsyncTask.h */,
1413E468189EEDE400546D68 /* BAssert.h */,
@@ -283,6 +290,8 @@
14D9DB4517F2447100EAAB79 /* FixedVector.h */,
1413E460189DCE1E00546D68 /* Inline.h */,
141D9AFF1C8E51C0000ABBA0 /* List.h */,
+ 4426E27E1C838EE0008EB042 /* Logging.cpp */,
+ 4426E27F1C838EE0008EB042 /* Logging.h */,
144DCED617A649D90093B2F2 /* Mutex.h */,
14446A0717A61FA400F9EA1D /* PerProcess.h */,
144469FD17A61F1F00F9EA1D /* PerThread.h */,
@@ -297,6 +306,14 @@
name = stdlib;
sourceTree = "<group>";
};
+ 4408F2961C9896C40012EC64 /* darwin */ = {
+ isa = PBXGroup;
+ children = (
+ 4426E2821C839547008EB042 /* BSoftLinking.h */,
+ );
+ name = darwin;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
@@ -328,6 +345,7 @@
14DD78CD18F48D7500950702 /* Range.h in Headers */,
14DD789C18F48D4A00950702 /* BumpAllocator.h in Headers */,
14DD789918F48D4A00950702 /* Cache.h in Headers */,
+ 4426E2831C839547008EB042 /* BSoftLinking.h in Headers */,
14DD789018F48CEB00950702 /* Sizes.h in Headers */,
14DD78C718F48D7500950702 /* BAssert.h in Headers */,
14DD78D018F48D7500950702 /* VMAllocate.h in Headers */,
@@ -340,6 +358,7 @@
1400274A18F89C2300115C97 /* VMHeap.h in Headers */,
1400274918F89C1300115C97 /* Heap.h in Headers */,
140FA00319CE429C00FFD3C8 /* BumpRange.h in Headers */,
+ 4426E2811C838EE0008EB042 /* Logging.h in Headers */,
14DD78C518F48D7500950702 /* Algorithm.h in Headers */,
14DD78BD18F48D6B00950702 /* SmallPage.h in Headers */,
14DD788E18F48CCD00950702 /* BoundaryTag.h in Headers */,
@@ -439,6 +458,7 @@
14F271C318EA3978008C152F /* Allocator.cpp in Sources */,
14895D911A3A319C0006235D /* Environment.cpp in Sources */,
143EF9AF1A9FABF6004F5C77 /* FreeList.cpp in Sources */,
+ 4426E2801C838EE0008EB042 /* Logging.cpp in Sources */,
14F271C718EA3990008C152F /* Heap.cpp in Sources */,
14F271C918EA3990008C152F /* VMHeap.cpp in Sources */,
144C07F41C7B70260051BB6A /* XLargeMap.cpp in Sources */,