Title: [218339] trunk/Source/WebCore
Revision
218339
Author
ddkil...@apple.com
Date
2017-06-15 10:05:04 -0700 (Thu, 15 Jun 2017)

Log Message

[iOS] Generate a simulated crash when the WebThread starts in MobileSafari
<https://webkit.org/b/173386>
<rdar://problem/32776426>

Reviewed by Andy Estes.

* WebCore.xcodeproj/project.pbxproj: Add new files to project.
* platform/ios/CrashReporterSupportSoftLink.h: Add.  The using
statement is so that we don't have to write
WebCore::SimulateCrash() in WebCoreThread.mm since it's
functions are not defined inside a WebCore namespace.  I also
kept the 'pid' argument despite the style checker warning
because it matches the internal method definition.
* platform/ios/CrashReporterSupportSoftLink.mm: Add.
* platform/ios/wak/WebCoreThread.mm: Sort headers.  Soft link to
CrashReporterSupport.framework.
(WebThreadEnable): Generate a simulated crash log if the
WebThread ever starts in MobileSafari.
* platform/spi/ios/CrashReporterSupportSPI.h: Add.  The header
isn't safe to include in C++ source, so wrap the import in
extern "C" macros.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (218338 => 218339)


--- trunk/Source/WebCore/ChangeLog	2017-06-15 17:01:26 UTC (rev 218338)
+++ trunk/Source/WebCore/ChangeLog	2017-06-15 17:05:04 UTC (rev 218339)
@@ -1,3 +1,27 @@
+2017-06-14  David Kilzer  <ddkil...@apple.com>
+
+        [iOS] Generate a simulated crash when the WebThread starts in MobileSafari
+        <https://webkit.org/b/173386>
+        <rdar://problem/32776426>
+
+        Reviewed by Andy Estes.
+
+        * WebCore.xcodeproj/project.pbxproj: Add new files to project.
+        * platform/ios/CrashReporterSupportSoftLink.h: Add.  The using
+        statement is so that we don't have to write
+        WebCore::SimulateCrash() in WebCoreThread.mm since it's
+        functions are not defined inside a WebCore namespace.  I also
+        kept the 'pid' argument despite the style checker warning
+        because it matches the internal method definition.
+        * platform/ios/CrashReporterSupportSoftLink.mm: Add.
+        * platform/ios/wak/WebCoreThread.mm: Sort headers.  Soft link to
+        CrashReporterSupport.framework.
+        (WebThreadEnable): Generate a simulated crash log if the
+        WebThread ever starts in MobileSafari.
+        * platform/spi/ios/CrashReporterSupportSPI.h: Add.  The header
+        isn't safe to include in C++ source, so wrap the import in
+        extern "C" macros.
+
 2017-06-15  Jonathan Bedard  <jbed...@apple.com>
 
         Build WebKit with High Sierra (Seed 1)

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (218338 => 218339)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-06-15 17:01:26 UTC (rev 218338)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-06-15 17:05:04 UTC (rev 218339)
@@ -1912,6 +1912,9 @@
 		44C991860F3D1EBE00586670 /* ScrollbarThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 44C991850F3D1EBE00586670 /* ScrollbarThemeIOS.h */; };
 		44C9919F0F3D210E00586670 /* ThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 44C9919D0F3D210E00586670 /* ThemeIOS.h */; };
 		44C991A00F3D210E00586670 /* ThemeIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 44C9919E0F3D210E00586670 /* ThemeIOS.mm */; };
+		44CA12961EF23A4F00E4B3AD /* CrashReporterSupportSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 44CA12941EF23A2000E4B3AD /* CrashReporterSupportSoftLink.h */; };
+		44CA12981EF23A6900E4B3AD /* CrashReporterSupportSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 44CA12971EF23A6500E4B3AD /* CrashReporterSupportSPI.h */; };
+		44CA129B1EF2D9E800E4B3AD /* CrashReporterSupportSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 44CA12951EF23A2000E4B3AD /* CrashReporterSupportSoftLink.mm */; };
 		44DAB5B115A623580097C1E4 /* Extensions3DOpenGLCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 44DAB5AF15A623580097C1E4 /* Extensions3DOpenGLCommon.cpp */; };
 		44DAB5B215A623580097C1E4 /* Extensions3DOpenGLCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 44DAB5B015A623580097C1E4 /* Extensions3DOpenGLCommon.h */; };
 		44DEF6431A6FF92700D45EEC /* IOReturnSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 44DEF6421A6FF92700D45EEC /* IOReturnSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9636,6 +9639,9 @@
 		44C991850F3D1EBE00586670 /* ScrollbarThemeIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollbarThemeIOS.h; sourceTree = "<group>"; };
 		44C9919D0F3D210E00586670 /* ThemeIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThemeIOS.h; sourceTree = "<group>"; };
 		44C9919E0F3D210E00586670 /* ThemeIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ThemeIOS.mm; sourceTree = "<group>"; };
+		44CA12941EF23A2000E4B3AD /* CrashReporterSupportSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrashReporterSupportSoftLink.h; sourceTree = "<group>"; };
+		44CA12951EF23A2000E4B3AD /* CrashReporterSupportSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CrashReporterSupportSoftLink.mm; sourceTree = "<group>"; };
+		44CA12971EF23A6500E4B3AD /* CrashReporterSupportSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrashReporterSupportSPI.h; sourceTree = "<group>"; };
 		44D8DA98139545BE00337B75 /* SVGMPathElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGMPathElement.idl; sourceTree = "<group>"; };
 		44D8DA9A139545CD00337B75 /* SVGAnimateMotionElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGAnimateMotionElement.idl; sourceTree = "<group>"; };
 		44DAB5AF15A623580097C1E4 /* Extensions3DOpenGLCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Extensions3DOpenGLCommon.cpp; sourceTree = "<group>"; };
@@ -21087,6 +21093,7 @@
 			isa = PBXGroup;
 			children = (
 				CE1252421A16C01A00864480 /* CoreUISPI.h */,
+				44CA12971EF23A6500E4B3AD /* CrashReporterSupportSPI.h */,
 				2DC4CF781D2DD98900ECCC94 /* DataDetectorsUISPI.h */,
 				CEC337AE1A46086D009B8523 /* GraphicsServicesSPI.h */,
 				7C4C96E21AD44ABF00365A50 /* LaunchServicesSPI.h */,
@@ -21122,6 +21129,8 @@
 			children = (
 				A148328B187F506800DA63A6 /* wak */,
 				F48223121E386E240066FC79 /* AbstractPasteboard.h */,
+				44CA12941EF23A2000E4B3AD /* CrashReporterSupportSoftLink.h */,
+				44CA12951EF23A2000E4B3AD /* CrashReporterSupportSoftLink.mm */,
 				2655414B1489AA2B000DFC5D /* CursorIOS.cpp */,
 				A1ED778A1BE3293F00DC1791 /* Device.cpp */,
 				A1ED778B1BE3294000DC1791 /* Device.h */,
@@ -26856,6 +26865,8 @@
 				BC5EB9510E82056B00B25965 /* CounterDirectives.h in Headers */,
 				9392F14C0AD1861B00691BD4 /* CounterNode.h in Headers */,
 				46C696CB1E7205F700597937 /* CPUMonitor.h in Headers */,
+				44CA12961EF23A4F00E4B3AD /* CrashReporterSupportSoftLink.h in Headers */,
+				44CA12981EF23A6900E4B3AD /* CrashReporterSupportSPI.h in Headers */,
 				D0B0556809C6700100307E43 /* CreateLinkCommand.h in Headers */,
 				514C766E0CE923A1007EF3CD /* Credential.h in Headers */,
 				3792917A1985EF3900F4B661 /* CredentialBase.h in Headers */,
@@ -30940,6 +30951,7 @@
 				BC5EB9500E82056B00B25965 /* CounterDirectives.cpp in Sources */,
 				9392F1500AD1862300691BD4 /* CounterNode.cpp in Sources */,
 				46C696CC1E7205FC00597937 /* CPUMonitor.cpp in Sources */,
+				44CA129B1EF2D9E800E4B3AD /* CrashReporterSupportSoftLink.mm in Sources */,
 				D0B0556909C6700100307E43 /* CreateLinkCommand.cpp in Sources */,
 				514C766D0CE923A1007EF3CD /* CredentialBase.cpp in Sources */,
 				3792917D1987678F00F4B661 /* CredentialCocoa.mm in Sources */,

Added: trunk/Source/WebCore/platform/ios/CrashReporterSupportSoftLink.h (0 => 218339)


--- trunk/Source/WebCore/platform/ios/CrashReporterSupportSoftLink.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/ios/CrashReporterSupportSoftLink.h	2017-06-15 17:05:04 UTC (rev 218339)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#if PLATFORM(IOS)
+
+#import "CrashReporterSupportSPI.h"
+#import "SoftLinking.h"
+
+SOFT_LINK_FRAMEWORK_FOR_HEADER(WebCore, CrashReporterSupport)
+
+SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CrashReporterSupport, SimulateCrash, BOOL, (pid_t pid, mach_exception_data_type_t exceptionCode, NSString *description), (pid, exceptionCode, description))
+#define SimulateCrash softLink_CrashReporterSupport_SimulateCrash
+
+using WebCore::softLink_CrashReporterSupport_SimulateCrash;
+
+#endif // PLATFORM(IOS)

Added: trunk/Source/WebCore/platform/ios/CrashReporterSupportSoftLink.mm (0 => 218339)


--- trunk/Source/WebCore/platform/ios/CrashReporterSupportSoftLink.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/ios/CrashReporterSupportSoftLink.mm	2017-06-15 17:05:04 UTC (rev 218339)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#import "config.h"
+
+#if PLATFORM(IOS)
+
+#import "CrashReporterSupportSPI.h"
+#import "SoftLinking.h"
+
+SOFT_LINK_PRIVATE_FRAMEWORK_FOR_SOURCE(WebCore, CrashReporterSupport)
+
+SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CrashReporterSupport, SimulateCrash, BOOL, (pid_t pid, mach_exception_data_type_t exceptionCode, NSString *description), (pid, exceptionCode, description));
+
+#endif // PLATFORM(IOS)

Modified: trunk/Source/WebCore/platform/ios/wak/WebCoreThread.mm (218338 => 218339)


--- trunk/Source/WebCore/platform/ios/wak/WebCoreThread.mm	2017-06-15 17:01:26 UTC (rev 218338)
+++ trunk/Source/WebCore/platform/ios/wak/WebCoreThread.mm	2017-06-15 17:05:04 UTC (rev 218339)
@@ -38,8 +38,12 @@
 #import "WebCoreThreadRun.h"
 #import "WKUtilities.h"
 
+#import <Foundation/NSInvocation.h>
+#import <libkern/OSAtomic.h>
+#import <objc/runtime.h>
 #import <runtime/InitializeThreading.h>
 #import <runtime/JSLock.h>
+#import <unistd.h>
 #import <wtf/Assertions.h>
 #import <wtf/MainThread.h>
 #import <wtf/RunLoop.h>
@@ -46,9 +50,7 @@
 #import <wtf/Threading.h>
 #import <wtf/text/AtomicString.h>
 
-#import <Foundation/NSInvocation.h>
-#import <libkern/OSAtomic.h>
-#import <objc/runtime.h>
+#import "CrashReporterSupportSoftLink.h"
 
 #define LOG_MESSAGES 0
 #define LOG_WEB_LOCK 0
@@ -1000,7 +1002,11 @@
 
 void WebThreadEnable(void)
 {
-    RELEASE_ASSERT_WITH_MESSAGE(!WebCore::IOSApplication::isWebProcess(), "The WebProcess should never run a Web Thread");
+    if (WebCore::IOSApplication::isMobileSafari()) {
+        const mach_exception_data_type_t kExceptionCode = 0xbbadd0b1; // "Bad Dub 1" or Bad WK1.
+        SimulateCrash(getpid(), kExceptionCode, @"MobileSafari should never run a WebThread");
+    }
+    RELEASE_ASSERT_WITH_MESSAGE(!WebCore::IOSApplication::isWebProcess(), "The WebProcess should never run a WebThread");
 
     static pthread_once_t initControl = PTHREAD_ONCE_INIT;
     pthread_once(&initControl, StartWebThread);

Added: trunk/Source/WebCore/platform/spi/ios/CrashReporterSupportSPI.h (0 => 218339)


--- trunk/Source/WebCore/platform/spi/ios/CrashReporterSupportSPI.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/spi/ios/CrashReporterSupportSPI.h	2017-06-15 17:05:04 UTC (rev 218339)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#import <Foundation/Foundation.h>
+#import <mach/exception_types.h>
+
+#if USE(APPLE_INTERNAL_SDK)
+
+WTF_EXTERN_C_BEGIN
+#import <CrashReporterSupport/CrashReporterSupport.h>
+WTF_EXTERN_C_END
+
+#endif
+
+WTF_EXTERN_C_BEGIN
+BOOL SimulateCrash(pid_t pid, mach_exception_data_type_t exceptionCode, NSString *description);
+WTF_EXTERN_C_END
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to