[iOS] ASSERTION FAILED: m_scriptExecutionContext->isContextThread() in ContextDestruc...
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Feb 2015 19:47:06 +0000 (19:47 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Feb 2015 19:47:06 +0000 (19:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141057
<rdar://problem/19068790>

Reviewed by Alexey Proskuryakov.

Source/JavaScriptCore:

* inspector/remote/RemoteInspector.mm:
(Inspector::RemoteInspector::receivedIndicateMessage): Modified to call WTF::callOnWebThreadOrDispatchAsyncOnMainThread().
(Inspector::dispatchAsyncOnQueueSafeForAnyDebuggable): Deleted; moved logic to common helper function,
WTF::callOnWebThreadOrDispatchAsyncOnMainThread() so that it can be called from both RemoteInspector::receivedIndicateMessage()
and CryptoKeyRSA::generatePair().

Source/WebCore:

Fixes an issue where we would create-/delete- the RSA crypto keys and dispatch callbacks on the wrong
thread in WebKit1 for iOS. In iOS WebKit1 we should perform such operations on thread WebThread.

This change is covered by existing layout tests.

* crypto/mac/CryptoKeyRSAMac.cpp:
(WebCore::CryptoKeyRSA::generatePair):

Source/WTF:

* wtf/MainThread.h:
* wtf/mac/MainThreadMac.mm:
(WTF::callOnWebThreadOrDispatchAsyncOnMainThread): Added.

LayoutTests:

Un-skip crypto tests. Also, group skip entries for tests crypto/subtle/{rsa-indexeddb, rsa-indexeddb-non-exportable}.html
with other skipped IndexedDB tests.

* platform/ios-simulator/TestExpectations:

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

LayoutTests/ChangeLog
LayoutTests/platform/ios-simulator/TestExpectations
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/remote/RemoteInspector.mm
Source/WTF/ChangeLog
Source/WTF/wtf/MainThread.h
Source/WTF/wtf/mac/MainThreadMac.mm
Source/WebCore/ChangeLog
Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp

index ed72020..a3fb8d1 100644 (file)
@@ -1,3 +1,16 @@
+2015-02-02  Daniel Bates  <dabates@apple.com>
+
+        [iOS] ASSERTION FAILED: m_scriptExecutionContext->isContextThread() in ContextDestructionObserver::observeContext
+        https://bugs.webkit.org/show_bug.cgi?id=141057
+        <rdar://problem/19068790>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Un-skip crypto tests. Also, group skip entries for tests crypto/subtle/{rsa-indexeddb, rsa-indexeddb-non-exportable}.html
+        with other skipped IndexedDB tests.
+
+        * platform/ios-simulator/TestExpectations:
+
 2015-02-01  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r179467 and r179470.
index cbae217..9fbb4bf 100644 (file)
@@ -70,6 +70,8 @@ http/tests/w3c/webperf
 # IndexedDB is not supported on iOS
 storage/indexeddb
 inspector-protocol/indexeddb/basics.html
+crypto/subtle/rsa-indexeddb-non-exportable.html
+crypto/subtle/rsa-indexeddb.html
 
 # Quota API is not supported on iOS
 storage/domstorage/quota.html
@@ -287,21 +289,9 @@ webkit.org/b/137530 canvas/philip/tests/2d.text.measure.width.space.html [ Failu
 # Canvas tests that have stderr:
 canvas/philip/tests/2d.canvas.readonly.html [ Skip ]
 
-# <rdar://problem/19068790> ASSERTION FAILED: m_scriptExecutionContext->isContextThread() in ContextDestructionObserver::observeContext
-crypto/subtle/rsa-oaep-generate-non-extractable-key.html [ Skip ]
-crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html [ Skip ]
-crypto/subtle/rsa-oaep-key-manipulation.html [ Skip ]
+# HTTP tests that time out:
 http/tests/security/XFrameOptions/x-frame-options-deny-delete-frame-in-load-event.html
 
-# <rdar://problem/19068796> ASSERTION FAILED: crypto/subtle/rsassa-pkcs1-v1_5-generate-key-with-leading-zeroes-in-exponent.html fails ASSERT(m_scriptExecutionContext->isContextThread())
-crypto/subtle/rsassa-pkcs1-v1_5-generate-key-with-leading-zeroes-in-exponent.html [ Skip ]
-
-# Crypto tests that time out:
-crypto/subtle/rsa-indexeddb-non-exportable.html
-crypto/subtle/rsa-indexeddb.html
-crypto/subtle/rsa-oaep-plaintext-length.html [ Skip ] # Timeout, Pass
-crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-small-key.html [ Skip ]
-
 # Compositing tests that fail:
 compositing/regions/abs-transformed-dynamic-update.html [ ImageOnlyFailure ]
 compositing/regions/fixed-in-diff-named-flows-zIndex.html [ ImageOnlyFailure ]
index 6e8389a..69703db 100644 (file)
@@ -1,3 +1,17 @@
+2015-02-02  Daniel Bates  <dabates@apple.com>
+
+        [iOS] ASSERTION FAILED: m_scriptExecutionContext->isContextThread() in ContextDestructionObserver::observeContext
+        https://bugs.webkit.org/show_bug.cgi?id=141057
+        <rdar://problem/19068790>
+
+        Reviewed by Alexey Proskuryakov.
+
+        * inspector/remote/RemoteInspector.mm:
+        (Inspector::RemoteInspector::receivedIndicateMessage): Modified to call WTF::callOnWebThreadOrDispatchAsyncOnMainThread().
+        (Inspector::dispatchAsyncOnQueueSafeForAnyDebuggable): Deleted; moved logic to common helper function,
+        WTF::callOnWebThreadOrDispatchAsyncOnMainThread() so that it can be called from both RemoteInspector::receivedIndicateMessage()
+        and CryptoKeyRSA::generatePair().
+
 2015-02-02  Saam Barati  <saambarati1@gmail.com>
 
         Create tests for JSC's Control Flow Profiler
index e810724..ea4a86f 100644 (file)
@@ -36,6 +36,7 @@
 #import <dispatch/dispatch.h>
 #import <notify.h>
 #import <wtf/Assertions.h>
+#import <wtf/MainThread.h>
 #import <wtf/NeverDestroyed.h>
 #import <wtf/spi/darwin/XPCSPI.h>
 #import <wtf/text/WTFString.h>
@@ -51,10 +52,6 @@ enum sandbox_filter_type {
 extern "C" int sandbox_check(pid_t, const char *operation, enum sandbox_filter_type, ...);
 extern "C" const enum sandbox_filter_type SANDBOX_CHECK_NO_REPORT;
 
-#if PLATFORM(IOS)
-#import <wtf/ios/WebCoreThread.h>
-#endif
-
 namespace Inspector {
 
 static bool canAccessWebInspectorMachPort()
@@ -73,18 +70,6 @@ static bool globalAutomaticInspectionState()
     return automaticInspectionEnabled == 1;
 }
 
-static void dispatchAsyncOnQueueSafeForAnyDebuggable(void (^block)())
-{
-#if PLATFORM(IOS)
-    if (WebCoreWebThreadIsEnabled && WebCoreWebThreadIsEnabled()) {
-        WebCoreWebThreadRun(block);
-        return;
-    }
-#endif
-
-    dispatch_async(dispatch_get_main_queue(), block);
-}
-
 bool RemoteInspector::startEnabled = true;
 
 void RemoteInspector::startDisabled()
@@ -643,7 +628,7 @@ void RemoteInspector::receivedIndicateMessage(NSDictionary *userInfo)
     unsigned identifier = [pageId unsignedIntValue];
     BOOL indicateEnabled = [[userInfo objectForKey:WIRIndicateEnabledKey] boolValue];
 
-    dispatchAsyncOnQueueSafeForAnyDebuggable(^{
+    callOnWebThreadOrDispatchAsyncOnMainThread(^{
         RemoteInspectorDebuggable* debuggable = nullptr;
         {
             std::lock_guard<std::mutex> lock(m_mutex);
index ae84930..3588cfb 100644 (file)
@@ -1,3 +1,15 @@
+2015-02-02  Daniel Bates  <dabates@apple.com>
+
+        [iOS] ASSERTION FAILED: m_scriptExecutionContext->isContextThread() in ContextDestructionObserver::observeContext
+        https://bugs.webkit.org/show_bug.cgi?id=141057
+        <rdar://problem/19068790>
+
+        Reviewed by Alexey Proskuryakov.
+
+        * wtf/MainThread.h:
+        * wtf/mac/MainThreadMac.mm:
+        (WTF::callOnWebThreadOrDispatchAsyncOnMainThread): Added.
+
 2015-01-31  Sam Weinig  <sam@webkit.org>
 
         Remove even more Mountain Lion support
index d54c708..c103db2 100644 (file)
@@ -46,6 +46,10 @@ WTF_EXPORT_PRIVATE void cancelCallOnMainThread(MainThreadFunction*, void* contex
 
 WTF_EXPORT_PRIVATE void callOnMainThread(std::function<void ()>);
 
+#if PLATFORM(COCOA)
+WTF_EXPORT_PRIVATE void callOnWebThreadOrDispatchAsyncOnMainThread(void (^block)());
+#endif
+
 WTF_EXPORT_PRIVATE void setMainThreadCallbacksPaused(bool paused);
 
 WTF_EXPORT_PRIVATE bool isMainThread();
@@ -94,6 +98,9 @@ void initializeMainThreadToProcessMainThreadPlatform();
 
 using WTF::callOnMainThread;
 using WTF::cancelCallOnMainThread;
+#if PLATFORM(COCOA)
+using WTF::callOnWebThreadOrDispatchAsyncOnMainThread;
+#endif
 using WTF::setMainThreadCallbacksPaused;
 using WTF::isMainThread;
 using WTF::isMainThreadOrGCThread;
index a14d328..a0e2e67 100644 (file)
@@ -31,6 +31,7 @@
 
 #import <CoreFoundation/CoreFoundation.h>
 #import <Foundation/NSThread.h>
+#import <dispatch/dispatch.h>
 #import <stdio.h>
 #import <wtf/Assertions.h>
 #import <wtf/HashSet.h>
@@ -142,6 +143,17 @@ void scheduleDispatchFunctionsOnMainThread()
     [staticMainThreadCaller performSelector:@selector(call) onThread:mainThreadNSThread withObject:nil waitUntilDone:NO];
 }
 
+void callOnWebThreadOrDispatchAsyncOnMainThread(void (^block)())
+{
+#if USE(WEB_THREAD)
+    if (WebCoreWebThreadIsEnabled && WebCoreWebThreadIsEnabled()) {
+        WebCoreWebThreadRun(block);
+        return;
+    }
+#endif
+    dispatch_async(dispatch_get_main_queue(), block);
+}
+
 #if USE(WEB_THREAD)
 static bool webThreadIsUninitializedOrLockedOrDisabled()
 {
index 3cfeea4..7cb46ed 100644 (file)
@@ -1,3 +1,19 @@
+2015-02-02  Daniel Bates  <dabates@apple.com>
+
+        [iOS] ASSERTION FAILED: m_scriptExecutionContext->isContextThread() in ContextDestructionObserver::observeContext
+        https://bugs.webkit.org/show_bug.cgi?id=141057
+        <rdar://problem/19068790>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Fixes an issue where we would create-/delete- the RSA crypto keys and dispatch callbacks on the wrong
+        thread in WebKit1 for iOS. In iOS WebKit1 we should perform such operations on thread WebThread.
+
+        This change is covered by existing layout tests.
+
+        * crypto/mac/CryptoKeyRSAMac.cpp:
+        (WebCore::CryptoKeyRSA::generatePair):
+
 2015-02-02  Jeremy Jones  <jeremyj@apple.com>
 
         Prevent crash when accessing WebAVPlayerController.delegate.
index b33a64e..1fabea3 100644 (file)
@@ -33,6 +33,7 @@
 #include "CryptoAlgorithmRegistry.h"
 #include "CryptoKeyDataRSAComponents.h"
 #include "CryptoKeyPair.h"
+#include <wtf/MainThread.h>
 
 namespace WebCore {
 
@@ -258,13 +259,13 @@ void CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier algorithm, unsigned mo
         CCCryptorStatus status = CCRSACryptorGeneratePair(modulusLength, e, &ccPublicKey, &ccPrivateKey);
         if (status) {
             WTFLogAlways("Could not generate a key pair, status %d", status);
-            dispatch_async(dispatch_get_main_queue(), ^{
+            callOnWebThreadOrDispatchAsyncOnMainThread(^{
                 (*localFailureCallback)();
                 delete localFailureCallback;
             });
             return;
         }
-        dispatch_async(dispatch_get_main_queue(), ^{
+        callOnWebThreadOrDispatchAsyncOnMainThread(^{
             RefPtr<CryptoKeyRSA> publicKey = CryptoKeyRSA::create(algorithm, CryptoKeyType::Public, ccPublicKey, true, usage);
             RefPtr<CryptoKeyRSA> privateKey = CryptoKeyRSA::create(algorithm, CryptoKeyType::Private, ccPrivateKey, extractable, usage);
             (*localCallback)(CryptoKeyPair::create(publicKey.release(), privateKey.release()));