DumpRenderTree should stop using CheckedMalloc.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Dec 2016 03:26:10 +0000 (03:26 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Dec 2016 03:26:10 +0000 (03:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165563
<rdar://problem/28945820>

Reviewed by Geoffrey Garen.

1. WebKitTestRunner does not have equivalent behavior to that which is implemented
   in CheckedMalloc.
2. bmalloc does not honor the settings of CheckedMalloc.

The only time CheckedMalloc comes into play is when DRT uses gmalloc or system
malloc.  As a result, DRT exhibits different behavior from the normal way we run
our tests.  We should obsolete CheckedMalloc and make DRT behave consistently
with WKTR.

* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/mac/CheckedMalloc.cpp: Removed.
* DumpRenderTree/mac/CheckedMalloc.h: Removed.
* DumpRenderTree/mac/DumpRenderTree.mm:
(prepareConsistentTestingEnvironment):

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

Tools/ChangeLog
Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
Tools/DumpRenderTree/mac/CheckedMalloc.cpp [deleted file]
Tools/DumpRenderTree/mac/CheckedMalloc.h [deleted file]
Tools/DumpRenderTree/mac/DumpRenderTree.mm

index bc9dd1a..9761b9f 100644 (file)
@@ -1,3 +1,26 @@
+2016-12-07  Mark Lam  <mark.lam@apple.com>
+
+        DumpRenderTree should stop using CheckedMalloc.
+        https://bugs.webkit.org/show_bug.cgi?id=165563
+        <rdar://problem/28945820>
+
+        Reviewed by Geoffrey Garen.
+
+        1. WebKitTestRunner does not have equivalent behavior to that which is implemented
+           in CheckedMalloc.
+        2. bmalloc does not honor the settings of CheckedMalloc.
+
+        The only time CheckedMalloc comes into play is when DRT uses gmalloc or system
+        malloc.  As a result, DRT exhibits different behavior from the normal way we run
+        our tests.  We should obsolete CheckedMalloc and make DRT behave consistently
+        with WKTR.
+
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/mac/CheckedMalloc.cpp: Removed.
+        * DumpRenderTree/mac/CheckedMalloc.h: Removed.
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (prepareConsistentTestingEnvironment):
+
 2016-12-07  Dean Jackson  <dino@apple.com>
 
         Remove runtime toggle for pointer-lock
index 6d9dc82..9780bec 100644 (file)
                A134E53618905EFF00901D06 /* AccessibilityCommonMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC0E26140E2DA4C6001B6BC3 /* AccessibilityCommonMac.mm */; };
                A8B91ADA0CF3B32F008F91FF /* DumpRenderTreePasteboard.m in Sources */ = {isa = PBXBuildFile; fileRef = A8B91AD70CF3B32F008F91FF /* DumpRenderTreePasteboard.m */; };
                A8B91ADC0CF3B32F008F91FF /* DumpRenderTreeWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8B91AD90CF3B32F008F91FF /* DumpRenderTreeWindow.mm */; };
-               A8B91BFD0CF522B4008F91FF /* CheckedMalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8B91BF70CF522B4008F91FF /* CheckedMalloc.cpp */; };
                A8D79CEB0FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m in Sources */ = {isa = PBXBuildFile; fileRef = A8D79CE90FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m */; };
                A9BB7C5C1C505278002C525B /* AccessibilityTextMarkerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9BB7C5B1C505278002C525B /* AccessibilityTextMarkerIOS.mm */; };
                AA5A15EF16E15CD000F7C561 /* AccessibilityControllerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = AA5A15ED16E15CD000F7C561 /* AccessibilityControllerIOS.mm */; };
                A8B91AD90CF3B32F008F91FF /* DumpRenderTreeWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DumpRenderTreeWindow.mm; path = mac/DumpRenderTreeWindow.mm; sourceTree = "<group>"; };
                A8B91ADD0CF3B372008F91FF /* DumpRenderTreeWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DumpRenderTreeWindow.h; path = mac/DumpRenderTreeWindow.h; sourceTree = "<group>"; };
                A8B91ADF0CF3B372008F91FF /* DumpRenderTreePasteboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DumpRenderTreePasteboard.h; path = mac/DumpRenderTreePasteboard.h; sourceTree = "<group>"; };
-               A8B91BF70CF522B4008F91FF /* CheckedMalloc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CheckedMalloc.cpp; path = mac/CheckedMalloc.cpp; sourceTree = "<group>"; };
-               A8B91BF90CF522B4008F91FF /* CheckedMalloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CheckedMalloc.h; path = mac/CheckedMalloc.h; sourceTree = "<group>"; };
                A8D79CE80FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumpRenderTreeFileDraggingSource.h; sourceTree = "<group>"; };
                A8D79CE90FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DumpRenderTreeFileDraggingSource.m; sourceTree = "<group>"; };
                A9BB7C5B1C505278002C525B /* AccessibilityTextMarkerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityTextMarkerIOS.mm; path = ios/AccessibilityTextMarkerIOS.mm; sourceTree = "<group>"; };
                                A803FF7409CAAD08009B2A37 /* DumpRenderTree.h */,
                                BCA18C460C9B5B9400114369 /* DumpRenderTree.mm */,
                                A134E52F188FC27000901D06 /* DumpRenderTreeMain.mm */,
-                               A8B91BF70CF522B4008F91FF /* CheckedMalloc.cpp */,
-                               A8B91BF90CF522B4008F91FF /* CheckedMalloc.h */,
                                7CBBC3211DDFCF9A00786B9D /* TestOptions.mm */,
                                7CBBC3221DDFCF9A00786B9D /* TestOptions.h */,
                                BC4741290D038A4C0072B006 /* JavaScriptThreading.h */,
                                AA5A15F016E15CD000F7C561 /* AccessibilityUIElementIOS.mm in Sources */,
                                BC0E26150E2DA4C6001B6BC2 /* AccessibilityUIElementMac.mm in Sources */,
                                BCA18B390C9B021900114369 /* AppleScriptController.m in Sources */,
-                               A8B91BFD0CF522B4008F91FF /* CheckedMalloc.cpp in Sources */,
                                53CBB832134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp in Sources */,
                                1A2FB84F178C80930059FD96 /* DefaultPolicyDelegate.m in Sources */,
                                BCA18C470C9B5B9400114369 /* DumpRenderTree.mm in Sources */,
diff --git a/Tools/DumpRenderTree/mac/CheckedMalloc.cpp b/Tools/DumpRenderTree/mac/CheckedMalloc.cpp
deleted file mode 100644 (file)
index a461d30..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
- *           (C) 2007 Graham Dennis (graham.dennis@gmail.com)
- *           (C) 2007 Eric Seidel <eric@webkit.org>
- *
- * 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. 
- * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE 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 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.
- */
-
-#import "config.h" 
-#import "CheckedMalloc.h"
-
-#import <WebCore/MachVMSPI.h>
-#import <mach/mach_init.h>
-#import <mach/vm_region.h>
-#import <malloc/malloc.h>
-#import <unistd.h>
-
-static void* (*savedMalloc)(malloc_zone_t*, size_t);
-static void* (*savedRealloc)(malloc_zone_t*, void*, size_t);
-
-static void* checkedMalloc(malloc_zone_t* zone, size_t size)
-{
-    if (size >= 0x10000000)
-        return 0;
-    return savedMalloc(zone, size);
-}
-
-static void* checkedRealloc(malloc_zone_t* zone, void* ptr, size_t size)
-{
-    if (size >= 0x10000000)
-        return 0;
-    return savedRealloc(zone, ptr, size);
-}
-
-static vm_prot_t protectionOfRegion(mach_vm_address_t address)
-{
-    mach_vm_size_t regionSize = 0;
-    vm_region_basic_info_64 regionInfo;
-    mach_msg_type_number_t regionInfoCount = VM_REGION_BASIC_INFO_COUNT_64;
-    mach_port_t objectName;
-    if (mach_vm_region(mach_task_self(), &address, &regionSize, VM_REGION_BASIC_INFO_64, (vm_region_info_t)&regionInfo, &regionInfoCount, &objectName))
-        CRASH();
-    return regionInfo.protection;
-}
-
-void makeLargeMallocFailSilently()
-{
-    malloc_zone_t* zone = malloc_default_zone();
-
-    mach_vm_address_t pageStart = reinterpret_cast<vm_address_t>(zone) & static_cast<vm_size_t>(~(getpagesize() - 1));
-    vm_prot_t initialProtection = protectionOfRegion(pageStart);
-
-    vm_size_t len = reinterpret_cast<vm_address_t>(zone) - pageStart + sizeof(malloc_zone_t);
-    if (mach_vm_protect(mach_task_self(), pageStart, len, 0, initialProtection | VM_PROT_WRITE))
-        CRASH();
-
-    savedMalloc = zone->malloc;
-    savedRealloc = zone->realloc;
-    zone->malloc = checkedMalloc;
-    zone->realloc = checkedRealloc;
-
-    if (mach_vm_protect(mach_task_self(), pageStart, len, 0, initialProtection))
-        CRASH();
-}
diff --git a/Tools/DumpRenderTree/mac/CheckedMalloc.h b/Tools/DumpRenderTree/mac/CheckedMalloc.h
deleted file mode 100644 (file)
index daee49b..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple, Inc.  All rights reserved.
- *           (C) 2007 Graham Dennis (graham.dennis@gmail.com)
- *           (C) 2007 Eric Seidel <eric@webkit.org>
- *
- * 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. 
- * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE 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 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.
- */
-
-void makeLargeMallocFailSilently();
index dc5817e..a90b5d0 100644 (file)
@@ -31,7 +31,6 @@
 #import "DumpRenderTree.h"
 
 #import "AccessibilityController.h"
-#import "CheckedMalloc.h"
 #import "DefaultPolicyDelegate.h"
 #import "DumpRenderTreeDraggingInfo.h"
 #import "DumpRenderTreePasteboard.h"
@@ -1247,8 +1246,6 @@ static void prepareConsistentTestingEnvironment()
     
     allocateGlobalControllers();
     
-    makeLargeMallocFailSilently();
-
 #if PLATFORM(MAC)
     NSActivityOptions options = (NSActivityUserInitiatedAllowingIdleSystemSleep | NSActivityLatencyCritical) & ~(NSActivitySuddenTerminationDisabled | NSActivityAutomaticTerminationDisabled);
     static id assertion = [[[NSProcessInfo processInfo] beginActivityWithOptions:options reason:@"DumpRenderTree should not be subject to process suppression"] retain];