diff options
author | Adam Vartanian <flooey@google.com> | 2018-05-15 11:28:41 +0100 |
---|---|---|
committer | Adam Vartanian <flooey@google.com> | 2018-05-15 11:28:41 +0100 |
commit | 1271f448571ee629e0bad47d70e30eeac549b549 (patch) | |
tree | 9a52c66f20870e6bd0ffe6e0494f0755aa55fd58 | |
parent | cb85d4e6605b8f26808acb6d0a3febea69bc466c (diff) | |
download | conscrypt-1271f448571ee629e0bad47d70e30eeac549b549.tar.gz |
Mitigate native crashes.
At least some of the native crashes are caused by race conditions
associated with some threads passing the isClosed() check at the
beginning of an operation while the close() method is executing.
Clearing the SSL variable before freeing the native resources should
reduce the frequency of this race condition.
Bug: 70507413
Test: cts -m CtsLibcoreTestCases -t com.android.org.conscrypt
Change-Id: Ibb5fef327ae1698ab362a7447e4b4150870ae93e
-rw-r--r-- | common/src/main/java/org/conscrypt/NativeSsl.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/common/src/main/java/org/conscrypt/NativeSsl.java b/common/src/main/java/org/conscrypt/NativeSsl.java index 8b559a7b..b55ed483 100644 --- a/common/src/main/java/org/conscrypt/NativeSsl.java +++ b/common/src/main/java/org/conscrypt/NativeSsl.java @@ -509,8 +509,9 @@ final class NativeSsl { } void close() { - NativeCrypto.SSL_free(ssl, this); + long previousSsl = ssl; ssl = 0L; + NativeCrypto.SSL_free(previousSsl, this); } boolean isClosed() { |