[Cocoa] Disable vnode guard related simulated crashes for WKTR / DRT and WebSQL
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2018 23:54:46 +0000 (23:54 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2018 23:54:46 +0000 (23:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187270
<rdar://problem/40674034>

Reviewed by Geoffrey Garen.

Source/WebCore:

Disable vnode guard related simulated crashes for WebSQL by setting the expected
environment variable, if not already set by WKTR / DRT.

* Modules/webdatabase/DatabaseManager.cpp:
(WebCore::DatabaseManager::initialize):
(WebCore::DatabaseManager::platformInitialize):
* Modules/webdatabase/DatabaseManager.h:
* Modules/webdatabase/cocoa/DatabaseManagerCocoa.mm: Added.
(WebCore::DatabaseManager::paltformInitialize):
* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/FileSystem.h:
* platform/posix/FileSystemPOSIX.cpp:
(WebCore::FileSystem::realPath):
* platform/win/FileSystemWin.cpp:
(WebCore::FileSystem::realPath):

Tools:

Disable vnode guard related simulated crashes for WKTR / DRT by setting the
expected environment variable in the test driver.

* Scripts/webkitpy/port/driver.py:
(Driver._setup_environ_for_driver):

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/DatabaseManager.cpp
Source/WebCore/Modules/webdatabase/DatabaseManager.h
Source/WebCore/Modules/webdatabase/cocoa/DatabaseManagerCocoa.mm [new file with mode: 0644]
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/FileSystem.h
Source/WebCore/platform/posix/FileSystemPOSIX.cpp
Source/WebCore/platform/win/FileSystemWin.cpp
Tools/ChangeLog
Tools/Scripts/webkitpy/port/driver.py

index f0b77d7..3d21a3e 100644 (file)
@@ -1,3 +1,28 @@
+2018-07-03  Chris Dumez  <cdumez@apple.com>
+
+        [Cocoa] Disable vnode guard related simulated crashes for WKTR / DRT and WebSQL
+        https://bugs.webkit.org/show_bug.cgi?id=187270
+        <rdar://problem/40674034>
+
+        Reviewed by Geoffrey Garen.
+
+        Disable vnode guard related simulated crashes for WebSQL by setting the expected
+        environment variable, if not already set by WKTR / DRT.
+
+        * Modules/webdatabase/DatabaseManager.cpp:
+        (WebCore::DatabaseManager::initialize):
+        (WebCore::DatabaseManager::platformInitialize):
+        * Modules/webdatabase/DatabaseManager.h:
+        * Modules/webdatabase/cocoa/DatabaseManagerCocoa.mm: Added.
+        (WebCore::DatabaseManager::paltformInitialize):
+        * SourcesCocoa.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/FileSystem.h:
+        * platform/posix/FileSystemPOSIX.cpp:
+        (WebCore::FileSystem::realPath):
+        * platform/win/FileSystemWin.cpp:
+        (WebCore::FileSystem::realPath):
+
 2018-07-03  Eric Carlson  <eric.carlson@apple.com>
 
         Don't allow autoplay when the element is suspended
index bbf4493..ffb7e86 100644 (file)
@@ -77,6 +77,7 @@ DatabaseManager& DatabaseManager::singleton()
 
 void DatabaseManager::initialize(const String& databasePath)
 {
+    platformInitialize(databasePath);
     DatabaseTracker::initializeTracker(databasePath);
 }
 
@@ -271,4 +272,11 @@ void DatabaseManager::logErrorMessage(ScriptExecutionContext& context, const Str
     context.addConsoleMessage(MessageSource::Storage, MessageLevel::Error, message);
 }
 
+#if !PLATFORM(COCOA)
+void DatabaseManager::platformInitialize(const String& databasePath)
+{
+    UNUSED_PARAM(databasePath);
+}
+#endif
+
 } // namespace WebCore
index 2cb4a44..91322e5 100644 (file)
@@ -72,6 +72,8 @@ private:
     DatabaseManager() = default;
     ~DatabaseManager() = delete;
 
+    void platformInitialize(const String& databasePath);
+
     enum OpenAttempt { FirstTryToOpenDatabase, RetryOpenDatabase };
     ExceptionOr<Ref<Database>> openDatabaseBackend(ScriptExecutionContext&, const String& name, const String& expectedVersion, const String& displayName, unsigned estimatedSize, bool setVersionInNewDatabase);
     ExceptionOr<Ref<Database>> tryToOpenDatabaseBackend(ScriptExecutionContext&, const String& name, const String& expectedVersion, const String& displayName, unsigned estimatedSize, bool setVersionInNewDatabase, OpenAttempt);
diff --git a/Source/WebCore/Modules/webdatabase/cocoa/DatabaseManagerCocoa.mm b/Source/WebCore/Modules/webdatabase/cocoa/DatabaseManagerCocoa.mm
new file mode 100644 (file)
index 0000000..7cfe9fb
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2018 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.
+ * 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 "DatabaseManager.h"
+
+#import "FileSystem.h"
+
+namespace WebCore {
+
+void DatabaseManager::platformInitialize(const String& databasePath)
+{
+    // The path needs to exist so that we can resolve it via realPath().
+    if (!FileSystem::fileExists(databasePath))
+        FileSystem::makeAllDirectories(databasePath);
+
+    // Disable vnode-guard related simulated crashes for WebSQL (rdar://problem/40674034). We do not overwrite the value here as it may have already been set by WKTR / DRT.
+    int overwrite = 0;
+    setenv("SQLITE_EXEMPT_PATH_FROM_VNODE_GUARDS", FileSystem::realPath(databasePath).utf8().data(), overwrite);
+}
+
+} // namespace WebCore
index 97fc9ee..f0b8e94 100644 (file)
@@ -26,6 +26,7 @@ Modules/mediasession/WebMediaSessionManager.cpp
 Modules/plugins/QuickTimePluginReplacement.mm
 Modules/plugins/YouTubePluginReplacement.cpp
 Modules/webauthn/cocoa/LocalAuthenticator.mm
+Modules/webdatabase/cocoa/DatabaseManagerCocoa.mm
 
 accessibility/ios/AccessibilityObjectIOS.mm
 accessibility/ios/AXObjectCacheIOS.mm
index ae619b4..e675cb6 100644 (file)
                463521AC2081090E00C28922 /* WindowProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowProxy.cpp; sourceTree = "<group>"; };
                463EB6201B8789CB0096ED51 /* TagCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TagCollection.cpp; sourceTree = "<group>"; };
                463EB6211B8789CB0096ED51 /* TagCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagCollection.h; sourceTree = "<group>"; };
+               4642404520EAF0ED00B29FD2 /* DatabaseManagerCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DatabaseManagerCocoa.mm; sourceTree = "<group>"; };
                465A8E781C8A24CE00E7D3E4 /* RuntimeApplicationChecksCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RuntimeApplicationChecksCocoa.mm; sourceTree = "<group>"; };
                466DC6AB1EDE021D00746224 /* JSDOMRectList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMRectList.cpp; sourceTree = "<group>"; };
                466ED8D21EDE0135005E43F6 /* JSDOMRectList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMRectList.h; sourceTree = "<group>"; };
                        path = ios;
                        sourceTree = "<group>";
                };
+               4642404420EAF0BD00B29FD2 /* cocoa */ = {
+                       isa = PBXGroup;
+                       children = (
+                               4642404520EAF0ED00B29FD2 /* DatabaseManagerCocoa.mm */,
+                       );
+                       path = cocoa;
+                       sourceTree = "<group>";
+               };
                49484FAE102CF01E00187DD3 /* canvas */ = {
                        isa = PBXGroup;
                        children = (
                97BC69D51505F054001B74AC /* webdatabase */ = {
                        isa = PBXGroup;
                        children = (
+                               4642404420EAF0BD00B29FD2 /* cocoa */,
                                FE36FD1116C7826400F887C1 /* ChangeVersionData.h */,
                                97BC69D81505F076001B74AC /* ChangeVersionWrapper.cpp */,
                                97BC69D91505F076001B74AC /* ChangeVersionWrapper.h */,
index 8530655..808f9a4 100644 (file)
@@ -186,6 +186,8 @@ String roamingUserSpecificStorageDirectory();
 WEBCORE_EXPORT NSString *createTemporaryDirectory(NSString *directoryPrefix);
 #endif
 
+WEBCORE_EXPORT String realPath(const String&);
+
 class MappedFileData {
 public:
     MappedFileData() { }
index 120ffb2..6b73206 100644 (file)
@@ -445,5 +445,13 @@ std::optional<int32_t> getFileDeviceId(const CString& fsFile)
     return fileStat.st_dev;
 }
 
+String realPath(const String& filePath)
+{
+    CString fsRep = fileSystemRepresentation(filePath);
+    char resolvedName[PATH_MAX];
+    const char* result = realpath(fsRep.data(), resolvedName);
+    return result ? String::fromUTF8(result) : filePath;
+}
+
 } // namespace FileSystem
 } // namespace WebCore
index e9e39d8..5436a26 100644 (file)
@@ -546,5 +546,10 @@ std::optional<int32_t> getFileDeviceId(const CString& fsFile)
     return fileInformation.dwVolumeSerialNumber;
 }
 
+String realPath(const String& filePath)
+{
+    return getFinalPathName(filePath);
+}
+
 } // namespace FileSystem
 } // namespace WebCore
index 31c13a0..c527a35 100644 (file)
@@ -1,3 +1,17 @@
+2018-07-03  Chris Dumez  <cdumez@apple.com>
+
+        [Cocoa] Disable vnode guard related simulated crashes for WKTR / DRT and WebSQL
+        https://bugs.webkit.org/show_bug.cgi?id=187270
+        <rdar://problem/40674034>
+
+        Reviewed by Geoffrey Garen.
+
+        Disable vnode guard related simulated crashes for WKTR / DRT by setting the
+        expected environment variable in the test driver.
+
+        * Scripts/webkitpy/port/driver.py:
+        (Driver._setup_environ_for_driver):
+
 2018-07-03  Eric Carlson  <eric.carlson@apple.com>
 
         Video sometimes flickers when playing to AppleTV
index f1295ca..29982ad 100644 (file)
@@ -367,6 +367,11 @@ class Driver(object):
         environment['LOCAL_RESOURCE_ROOT'] = str(self._port.layout_tests_dir())
         environment['ASAN_OPTIONS'] = "allocator_may_return_null=1"
         environment['__XPC_ASAN_OPTIONS'] = environment['ASAN_OPTIONS']
+
+        # Disable vnode-guard related simulated crashes for WKTR / DRT (rdar://problem/40674034).
+        environment['SQLITE_EXEMPT_PATH_FROM_VNODE_GUARDS'] = os.path.realpath(environment['DUMPRENDERTREE_TEMP'])
+        environment['__XPC_SQLITE_EXEMPT_PATH_FROM_VNODE_GUARDS'] = environment['SQLITE_EXEMPT_PATH_FROM_VNODE_GUARDS']
+
         if self._profiler:
             environment = self._profiler.adjusted_environment(environment)
         return environment