- Revision
- 209059
- Author
- [email protected]
- Date
- 2016-11-28 20:49:54 -0800 (Mon, 28 Nov 2016)
Log Message
ASSERTION FAILED: m_scriptExecutionContext->isContextThread() seen with LayoutTest crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html
https://bugs.webkit.org/show_bug.cgi?id=165124
<rdar://problem/29413805>
Reviewed by Daniel Bates.
We should only dereference callbacks after being back to the Document/Worker threads as
it might destroy promises in the work queue which will then trigger the assertion.
Covered by existing tests.
* crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
(WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
(WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
* crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt):
* crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
(WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (209058 => 209059)
--- trunk/Source/WebCore/ChangeLog 2016-11-29 04:29:55 UTC (rev 209058)
+++ trunk/Source/WebCore/ChangeLog 2016-11-29 04:49:54 UTC (rev 209059)
@@ -1,3 +1,26 @@
+2016-11-28 Jiewen Tan <[email protected]>
+
+ ASSERTION FAILED: m_scriptExecutionContext->isContextThread() seen with LayoutTest crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html
+ https://bugs.webkit.org/show_bug.cgi?id=165124
+ <rdar://problem/29413805>
+
+ Reviewed by Daniel Bates.
+
+ We should only dereference callbacks after being back to the Document/Worker threads as
+ it might destroy promises in the work queue which will then trigger the assertion.
+
+ Covered by existing tests.
+
+ * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
+ (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt):
+ (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt):
+ * crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp:
+ (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt):
+ (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt):
+ * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:
+ (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt):
+ (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt):
+
2016-11-28 Darin Adler <[email protected]>
Streamline and speed up tokenizer and segmented string classes
Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp (209058 => 209059)
--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp 2016-11-29 04:29:55 UTC (rev 209058)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp 2016-11-29 04:49:54 UTC (rev 209059)
@@ -82,13 +82,15 @@
ASSERT(aesParameters.ivVector().size() == kCCBlockSizeAES128);
auto result = transformAES_CBC(kCCEncrypt, aesParameters.ivVector().data(), aesKey.key(), plainText.data(), plainText.size());
if (result.hasException()) {
- context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
+ // We should only derenference callbacks after being back to the Document/Worker threads.
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) {
exceptionCallback(ec);
context.deref();
});
return;
}
- context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
+ // We should only derenference callbacks after being back to the Document/Worker threads.
+ context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) {
callback(result);
context.deref();
});
@@ -104,13 +106,15 @@
assert(aesParameters.ivVector().size() == kCCBlockSizeAES128);
auto result = transformAES_CBC(kCCDecrypt, aesParameters.ivVector().data(), aesKey.key(), cipherText.data(), cipherText.size());
if (result.hasException()) {
- context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
+ // We should only derenference callbacks after being back to the Document/Worker threads.
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) {
exceptionCallback(ec);
context.deref();
});
return;
}
- context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
+ // We should only derenference callbacks after being back to the Document/Worker threads.
+ context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) {
callback(result);
context.deref();
});
Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp (209058 => 209059)
--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp 2016-11-29 04:29:55 UTC (rev 209058)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp 2016-11-29 04:49:54 UTC (rev 209059)
@@ -67,13 +67,15 @@
auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
auto result = encryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText.data(), plainText.size());
if (result.hasException()) {
- context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
+ // We should only derenference callbacks after being back to the Document/Worker threads.
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) {
exceptionCallback(ec);
context.deref();
});
return;
}
- context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
+ // We should only derenference callbacks after being back to the Document/Worker threads.
+ context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) {
callback(result);
context.deref();
});
@@ -87,13 +89,15 @@
auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
auto result = decryptRSAES_PKCS1_v1_5(rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText.data(), cipherText.size());
if (result.hasException()) {
- context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
+ // We should only derenference callbacks after being back to the Document/Worker threads.
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) {
exceptionCallback(ec);
context.deref();
});
return;
}
- context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
+ // We should only derenference callbacks after being back to the Document/Worker threads.
+ context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) {
callback(result);
context.deref();
});
Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp (209058 => 209059)
--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp 2016-11-29 04:29:55 UTC (rev 209058)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp 2016-11-29 04:49:54 UTC (rev 209059)
@@ -78,13 +78,15 @@
auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
auto result = encryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), plainText.data(), plainText.size());
if (result.hasException()) {
- context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
+ // We should only derenference callbacks after being back to the Document/Worker threads.
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) {
exceptionCallback(ec);
context.deref();
});
return;
}
- context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
+ // We should only derenference callbacks after being back to the Document/Worker threads.
+ context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) {
callback(result);
context.deref();
});
@@ -99,13 +101,15 @@
auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
auto result = decryptRSA_OAEP(rsaKey.hashAlgorithmIdentifier(), rsaParameters.labelVector(), rsaKey.platformKey(), rsaKey.keySizeInBits(), cipherText.data(), cipherText.size());
if (result.hasException()) {
- context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code()](ScriptExecutionContext& context) {
+ // We should only derenference callbacks after being back to the Document/Worker threads.
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) {
exceptionCallback(ec);
context.deref();
});
return;
}
- context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue()](ScriptExecutionContext& context) {
+ // We should only derenference callbacks after being back to the Document/Worker threads.
+ context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) {
callback(result);
context.deref();
});