Skip to content

fix: close frameReader before socket in stopIfNecessary to prevent TSAN data race - #12949

Open
waterWang wants to merge 1 commit into
grpc:masterfrom
waterWang:fix/okhttp-client-transport-tsan-data-race-10294
Open

fix: close frameReader before socket in stopIfNecessary to prevent TSAN data race#12949
waterWang wants to merge 1 commit into
grpc:masterfrom
waterWang:fix/okhttp-client-transport-tsan-data-race-10294

Conversation

@waterWang

Copy link
Copy Markdown

Fixes #10294

Description

The thread reads from the socket while closes the same socket on the thread. This causes a TSAN-detected data race in the JVM's SSL Cipher state:

  • Thread T56 (SerializingExecutor): → → → (READ)
  • Thread T57 (thread pool): → → → (WRITE)

Fix

In , close the 's before closing the (which triggers the socket close). This ensures the reader thread is stopped before the socket is closed, preventing the data race.

The causes the loop to exit, and its block handles the idempotently.

@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OkHttp TlsTest TSAN data race

1 participant