Skip to content

OkHttp TlsTest TSAN data race  #10294

Open
@tonyjongyoonan

Description

@tonyjongyoonan

The bug described in #10284 was fixed by placing locks and removing the use of the bareSocket in #10279. Fixing this bug uncovered another underlying issue from a different code path.

TSAN reports:

SanitizerError
ThreadSanitizer: data race Cipher.java:1790 in javax.crypto.Cipher.checkCipherState()V (//third_party/java_src/grpc/okhttp:src/test/java/io/grpc/okhttp/TlsTest); see [http://go/sanitizer-blaze-warning](https://www.google.com/url?q=http://go/sanitizer-blaze-warning&sa=D)
Details
==================
WARNING: ThreadSanitizer: data race (pid=507)
  Read of size 4 at 0x0000cebeef54 by thread T56:
    #0 javax.crypto.Cipher.checkCipherState()V Cipher.java:1790 
    #1 javax.crypto.Cipher.doFinal()[B Cipher.java:2083 
    #2 sun.security.ssl.SSLCipher$T12GcmReadCipherGenerator$GcmReadCipher.dispose()V SSLCipher.java:1684 
    #3 sun.security.ssl.InputRecord.close()V InputRecord.java:103 
    #4 sun.security.ssl.TransportContext.initiateInboundClose()V TransportContext.java:545 
    #5 sun.security.ssl.TransportContext.closeInbound()V TransportContext.java:497 
    #6 sun.security.ssl.SSLSocketImpl.shutdownInput(Z)V SSLSocketImpl.java:847 
    #7 sun.security.ssl.SSLSocketImpl.bruteForceCloseInput(Z)V SSLSocketImpl.java:799 
    #8 sun.security.ssl.SSLSocketImpl.duplexCloseOutput()V SSLSocketImpl.java:661 
    #9 sun.security.ssl.SSLSocketImpl.close()V SSLSocketImpl.java:585 
    #10 sun.security.ssl.SSLSocketImpl$AppOutputStream.close()V SSLSocketImpl.java:1329 
    #11 okio.OutputStreamSink.close()V JvmOkio.kt:72 
    #12 okio.AsyncTimeout$sink$1.close()V AsyncTimeout.kt:109 
    #13 io.grpc.okhttp.AsyncSink$3.run()V AsyncSink.java:209 
    #14 io.grpc.internal.SerializingExecutor.run()V SerializingExecutor.java:133 
    #15 java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/concurrent/ThreadPoolExecutor$Worker;)V ThreadPoolExecutor.java:1130 
    #16 java.util.concurrent.ThreadPoolExecutor$Worker.run()V ThreadPoolExecutor.java:630 
    #17 java.lang.Thread.run()V Thread.java:830 
    #18 (Generated Stub) <null> 

  Previous write of size 4 at 0x0000cebeef54 by thread T57:
    #0 javax.crypto.Cipher.init(ILjava/security/Key;Ljava/security/spec/AlgorithmParameterSpec;Ljava/security/SecureRandom;)V Cipher.java:1438 
    #1 sun.security.ssl.SSLCipher$T12GcmReadCipherGenerator$GcmReadCipher.decrypt(BLjava/nio/ByteBuffer;[B)Lsun/security/ssl/Plaintext; SSLCipher.java:1636 
    #2 sun.security.ssl.SSLSocketInputRecord.decodeInputRecord()[Lsun/security/ssl/Plaintext; SSLSocketInputRecord.java:260 
    #3 sun.security.ssl.SSLSocketInputRecord.decode([Ljava/nio/ByteBuffer;II)[Lsun/security/ssl/Plaintext; SSLSocketInputRecord.java:181 
    #4 sun.security.ssl.SSLTransport.decode(Lsun/security/ssl/TransportContext;[Ljava/nio/ByteBuffer;II[Ljava/nio/ByteBuffer;II)Lsun/security/ssl/Plaintext; SSLTransport.java:111 
    #5 sun.security.ssl.SSLSocketImpl.decode(Ljava/nio/ByteBuffer;)Lsun/security/ssl/Plaintext; SSLSocketImpl.java:1509 
    #6 sun.security.ssl.SSLSocketImpl.readApplicationRecord(Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer; SSLSocketImpl.java:1476 
    #7 sun.security.ssl.SSLSocketImpl$AppInputStream.read([BII)I SSLSocketImpl.java:1065 
    #8 okio.InputStreamSource.read(Lokio/Buffer;J)J JvmOkio.kt:94 
    #9 okio.AsyncTimeout$source$1.read(Lokio/Buffer;J)J AsyncTimeout.kt:125 
    #10 okio.RealBufferedSource.request(J)Z RealBufferedSource.kt:206 
    #11 okio.RealBufferedSource.require(J)V RealBufferedSource.kt:199 
    #12 io.grpc.okhttp.internal.framed.Http2$Reader.nextFrame(Lio/grpc/okhttp/internal/framed/FrameReader$Handler;)Z Http2.java:120 
    #13 io.grpc.okhttp.OkHttpClientTransport$ClientFrameHandler.run()V OkHttpClientTransport.java:1105 
    #14 java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/concurrent/ThreadPoolExecutor$Worker;)V ThreadPoolExecutor.java:1130 
    #15 java.util.concurrent.ThreadPoolExecutor$Worker.run()V ThreadPoolExecutor.java:630 
    #16 java.lang.Thread.run()V Thread.java:830 
    #17 (Generated Stub) <null> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions